|
|
@@ -0,0 +1,241 @@
|
|
|
+`timescale 1ns/1ps
|
|
|
+
|
|
|
+// 6400 final top: shared host UART endpoint + transaction core + duty bank +
|
|
|
+// PWM carrier + temperature chain + watchdog, on the single new frame
|
|
|
+// protocol (A5 5A | TYPE | LEN:u8 | PAYLOAD | CRC16-CCITT-FALSE, low first).
|
|
|
+//
|
|
|
+// Data path:
|
|
|
+// host RS232/TTL -> host_uart_endpoint (RX parse, TX broadcast, independent
|
|
|
+// RX/TX CRC) -> request RAM -> m6400_transaction_core (validate, atomic
|
|
|
+// SET commit, GET assembly, NACK) -> duty_register_bank -> pwm_bitmap_engine
|
|
|
+// (+ fan_board_output_adapter) -> PTC/FAN pins.
|
|
|
+// temp_ram <- bmc_ascii_poll / ct7428_scan; get_data_6400 reads the bank and
|
|
|
+// temp_ram into reply_ram; reply_arbiter serialises reply groups vs DONEs
|
|
|
+// (6400 never produces DONEs; the port is tied off).
|
|
|
+// watchdog_30s reloads on SET_ACCEPT / GET_ACCEPT and invalidates the bank
|
|
|
+// on expiry (defaults PTC 0 / FAN 20 at the connector).
|
|
|
+//
|
|
|
+// Bank read-port arbitration: the duty bank has one read port. The PWM
|
|
|
+// scanner owns it except while a GET group is being assembled, when the GET
|
|
|
+// assembler owns it. The bitmap source is therefore fixed for a whole PWM
|
|
|
+// period except across a GET assembly window, which never overlaps a commit
|
|
|
+// (the core serialises transactions).
|
|
|
+module prod2u_6400_final_top (
|
|
|
+ input wire sys_clk,
|
|
|
+ input wire host_rs232_rx,
|
|
|
+ output wire host_rs232_tx,
|
|
|
+ input wire host_ttl_rx,
|
|
|
+ output wire host_ttl_tx,
|
|
|
+ input wire bmc_rs232_rx,
|
|
|
+ output wire bmc_rs232_tx,
|
|
|
+ output wire [23:0] ptc_pwm_out,
|
|
|
+ output wire [3:0] front_fan_pwm_out,
|
|
|
+ output wire [3:0] rear_fan_pwm_out,
|
|
|
+ inout wire temp_scl,
|
|
|
+ inout wire temp_sda
|
|
|
+);
|
|
|
+ wire sys_rst_n;
|
|
|
+ prod2u_por u_por (.sys_clk(sys_clk), .sys_rst_n(sys_rst_n));
|
|
|
+
|
|
|
+ // ---------- host UART endpoint ----------
|
|
|
+ wire req_valid;
|
|
|
+ wire req_ready;
|
|
|
+ wire [7:0] req_type;
|
|
|
+ wire [7:0] req_length;
|
|
|
+ wire req_ram_wr_en;
|
|
|
+ wire [7:0] req_ram_wr_addr;
|
|
|
+ wire [7:0] req_ram_wr_data;
|
|
|
+ wire [7:0] req_ram_rd_addr_core;
|
|
|
+ wire [7:0] req_ram_rd_data;
|
|
|
+ wire tx_start;
|
|
|
+ wire [7:0] tx_type;
|
|
|
+ wire [7:0] tx_length;
|
|
|
+ wire tx_busy;
|
|
|
+ wire tx_done;
|
|
|
+ wire [7:0] tx_ram_rd_addr;
|
|
|
+ wire [7:0] tx_ram_rd_data;
|
|
|
+
|
|
|
+ host_uart_endpoint u_host (
|
|
|
+ .clk(sys_clk), .rst_n(sys_rst_n),
|
|
|
+ .rs232_rx(host_rs232_rx), .rs232_tx(host_rs232_tx),
|
|
|
+ .ttl_rx(host_ttl_rx), .ttl_tx(host_ttl_tx),
|
|
|
+ .req_valid(req_valid), .req_ready(req_ready),
|
|
|
+ .req_type(req_type), .req_length(req_length),
|
|
|
+ .req_ram_wr_en(req_ram_wr_en),
|
|
|
+ .req_ram_wr_addr(req_ram_wr_addr),
|
|
|
+ .req_ram_wr_data(req_ram_wr_data),
|
|
|
+ .req_ram_rd_addr(), .req_ram_rd_data(8'd0),
|
|
|
+ .tx_start(tx_start), .tx_type(tx_type), .tx_length(tx_length),
|
|
|
+ .tx_busy(tx_busy), .tx_done(tx_done),
|
|
|
+ .tx_ram_rd_addr(tx_ram_rd_addr), .tx_ram_rd_data(tx_ram_rd_data)
|
|
|
+ );
|
|
|
+
|
|
|
+ // ---------- request staging RAM (128 x 8, synchronous read) ----------
|
|
|
+ ef2_bram_dp #(.DATA_WIDTH(8), .ADDR_WIDTH(7), .DATA_DEPTH(128)) u_req_ram (
|
|
|
+ .clk(sys_clk),
|
|
|
+ .a_en(req_ram_wr_en), .a_we(req_ram_wr_en),
|
|
|
+ .a_addr(req_ram_wr_addr[6:0]), .a_wdata(req_ram_wr_data), .a_rdata(),
|
|
|
+ .b_en(1'b1), .b_we(1'b0),
|
|
|
+ .b_addr(req_ram_rd_addr_core[6:0]), .b_wdata(8'd0), .b_rdata(req_ram_rd_data)
|
|
|
+ );
|
|
|
+
|
|
|
+ // ---------- reply staging RAM (128 x 8) ----------
|
|
|
+ wire reply_wr_en;
|
|
|
+ wire [7:0] reply_wr_addr;
|
|
|
+ wire [7:0] reply_wr_data;
|
|
|
+ wire gd_reply_we;
|
|
|
+ wire [7:0] gd_reply_addr;
|
|
|
+ wire [7:0] gd_reply_data;
|
|
|
+ wire nack_we;
|
|
|
+ wire [7:0] nack_addr;
|
|
|
+ wire [7:0] nack_data;
|
|
|
+ // Reply write-port share: GET assembly and NACK staging never run together.
|
|
|
+ assign reply_wr_en = gd_reply_we | nack_we;
|
|
|
+ assign reply_wr_addr = gd_reply_we ? gd_reply_addr : nack_addr;
|
|
|
+ assign reply_wr_data = gd_reply_we ? gd_reply_data : nack_data;
|
|
|
+ reply_ram u_reply_ram (
|
|
|
+ .clk(sys_clk),
|
|
|
+ .wr_en(reply_wr_en), .wr_addr(reply_wr_addr), .wr_data(reply_wr_data),
|
|
|
+ .rd_addr(tx_ram_rd_addr), .rd_data(tx_ram_rd_data)
|
|
|
+ );
|
|
|
+
|
|
|
+ // ---------- duty bank ----------
|
|
|
+ wire [4:0] bank_rd_addr;
|
|
|
+ wire [7:0] pwm_duty;
|
|
|
+ wire [4:0] pwm_addr;
|
|
|
+ wire stage_we;
|
|
|
+ wire [4:0] stage_addr;
|
|
|
+ wire [7:0] stage_data;
|
|
|
+ wire commit;
|
|
|
+ wire invalidate;
|
|
|
+ wire bank_valid;
|
|
|
+ // Read-port arbitration: GET assembly owns the port while it runs.
|
|
|
+ wire get_assembling;
|
|
|
+ assign bank_rd_addr = get_assembling ? gd_bank_addr : pwm_addr;
|
|
|
+ wire [4:0] gd_bank_addr;
|
|
|
+ wire [7:0] gd_bank_duty;
|
|
|
+ duty_register_bank #(.CHANNEL_COUNT(32), .ADDR_WIDTH(5),
|
|
|
+ .DEFAULT_PTC_MASK(32'h00FFFFFF)) u_bank (
|
|
|
+ .clk(sys_clk), .rst_n(sys_rst_n),
|
|
|
+ .pwm_addr(bank_rd_addr), .pwm_duty(pwm_duty),
|
|
|
+ .stage_we(stage_we), .stage_addr(stage_addr), .stage_data(stage_data),
|
|
|
+ .commit(commit), .invalidate(invalidate),
|
|
|
+ .valid(bank_valid), .active_bank()
|
|
|
+ );
|
|
|
+ // The GET assembler sees the bank output one clock after its address;
|
|
|
+ // its present/settle/commit rhythm already accounts for that.
|
|
|
+ assign gd_bank_duty = pwm_duty;
|
|
|
+
|
|
|
+ // ---------- temperature RAM + sensors ----------
|
|
|
+ wire temp_wr_en;
|
|
|
+ wire [5:0] temp_wr_addr;
|
|
|
+ wire [7:0] temp_wr_data;
|
|
|
+ wire [5:0] gd_temp_addr;
|
|
|
+ wire [7:0] gd_temp_data;
|
|
|
+ wire gd_temp_valid;
|
|
|
+ temp_ram u_temp_ram (
|
|
|
+ .clk(sys_clk),
|
|
|
+ .wr_en(temp_wr_en), .wr_addr(temp_wr_addr), .wr_data(temp_wr_data),
|
|
|
+ .rd_addr(gd_temp_addr), .rd_data(gd_temp_data), .rd_valid(gd_temp_valid)
|
|
|
+ );
|
|
|
+
|
|
|
+ // ---------- transaction core ----------
|
|
|
+ wire group_valid;
|
|
|
+ wire group_second;
|
|
|
+ wire [7:0] group_type;
|
|
|
+ wire [7:0] group_length;
|
|
|
+ wire [7:0] second_type;
|
|
|
+ wire [7:0] second_length;
|
|
|
+ wire [7:0] group_base;
|
|
|
+ wire [7:0] second_base;
|
|
|
+ wire group_done;
|
|
|
+ wire get_busy;
|
|
|
+ wire gd_start;
|
|
|
+ wire wd_arm;
|
|
|
+ wire wd_reload;
|
|
|
+ wire wd_expired;
|
|
|
+ wire wd_counting;
|
|
|
+
|
|
|
+ m6400_transaction_core u_core (
|
|
|
+ .clk(sys_clk), .rst_n(sys_rst_n),
|
|
|
+ .req_valid(req_valid), .req_ready(req_ready),
|
|
|
+ .req_type(req_type), .req_length(req_length),
|
|
|
+ .req_ram_rd_addr(req_ram_rd_addr_core), .req_ram_rd_data(req_ram_rd_data),
|
|
|
+ .stage_we(stage_we), .stage_addr(stage_addr), .stage_data(stage_data),
|
|
|
+ .commit(commit), .invalidate(invalidate),
|
|
|
+ .gd_start(gd_start),
|
|
|
+ .gd_bank_addr(gd_bank_addr), .gd_bank_duty(gd_bank_duty),
|
|
|
+ .gd_temp_addr(gd_temp_addr), .gd_temp_data(gd_temp_data),
|
|
|
+ .gd_temp_valid(gd_temp_valid),
|
|
|
+ .gd_reply_we(gd_reply_we), .gd_reply_addr(gd_reply_addr),
|
|
|
+ .gd_reply_data(gd_reply_data),
|
|
|
+ .group_valid(group_valid), .group_second(group_second),
|
|
|
+ .group_type(group_type), .group_length(group_length),
|
|
|
+ .second_type(second_type), .second_length(second_length),
|
|
|
+ .group_base(group_base), .second_base(second_base),
|
|
|
+ .group_done(group_done),
|
|
|
+ .get_busy(get_busy),
|
|
|
+ .nack_we(nack_we), .nack_addr(nack_addr), .nack_data(nack_data),
|
|
|
+ .wd_arm(wd_arm), .wd_reload(wd_reload), .wd_expired(wd_expired)
|
|
|
+ );
|
|
|
+ // The core raises get_busy while a GET group is being assembled; that flag
|
|
|
+ // owns the bank read port for the duration.
|
|
|
+ assign get_assembling = get_busy;
|
|
|
+
|
|
|
+ // ---------- reply arbiter ----------
|
|
|
+ wire [3:0] done_grant;
|
|
|
+ wire done_launch;
|
|
|
+ wire [7:0] arb_base;
|
|
|
+ reply_arbiter u_arb (
|
|
|
+ .clk(sys_clk), .rst_n(sys_rst_n),
|
|
|
+ .group_valid(group_valid), .group_second(group_second),
|
|
|
+ .group_type(group_type), .group_length(group_length),
|
|
|
+ .second_type(second_type), .second_length(second_length),
|
|
|
+ .group_base(group_base), .second_base(second_base),
|
|
|
+ .group_done(group_done),
|
|
|
+ .done_pending(16'd0), .done_axis_grant(done_grant),
|
|
|
+ .done_launch(done_launch), .done_ready(1'b0),
|
|
|
+ .tx_start(tx_start), .tx_type(tx_type), .tx_length(tx_length),
|
|
|
+ .tx_base(arb_base),
|
|
|
+ .tx_busy(tx_busy), .tx_done(tx_done)
|
|
|
+ );
|
|
|
+
|
|
|
+ // ---------- watchdog ----------
|
|
|
+ watchdog_30s #(.TIMEOUT_CLKS(750000000)) u_wd (
|
|
|
+ .clk(sys_clk), .rst_n(sys_rst_n),
|
|
|
+ .arm(wd_arm), .reload(wd_reload),
|
|
|
+ .expired(wd_expired), .counting(wd_counting)
|
|
|
+ );
|
|
|
+
|
|
|
+ // ---------- PWM carrier + board adapter (existing, reused) ----------
|
|
|
+ wire [31:0] logical_bitmap;
|
|
|
+ wire pwm_phase_boundary;
|
|
|
+ wire pwm_deadline_miss;
|
|
|
+ wire [6:0] pwm_phase_value;
|
|
|
+ wire pwm_scan_idle;
|
|
|
+ pwm_bitmap_engine #(.CHANNEL_COUNT(32)) u_pwm (
|
|
|
+ .clk(sys_clk), .rst_n(sys_rst_n),
|
|
|
+ .runtime_duty_ready(bank_valid),
|
|
|
+ .duty_rd_addr(pwm_addr), .duty_rd_data(pwm_duty),
|
|
|
+ .logical_bitmap(logical_bitmap),
|
|
|
+ .phase_boundary(pwm_phase_boundary),
|
|
|
+ .phase_boundary_advance(),
|
|
|
+ .deadline_miss(pwm_deadline_miss),
|
|
|
+ .phase_value(pwm_phase_value),
|
|
|
+ .scan_idle(pwm_scan_idle)
|
|
|
+ );
|
|
|
+
|
|
|
+ wire [3:0] front_ball;
|
|
|
+ wire [3:0] rear_ball;
|
|
|
+ fan_board_output_adapter u_fan_adapter (
|
|
|
+ .logical_fan_on(logical_bitmap[31:24]),
|
|
|
+ .front_fan_ball(front_ball),
|
|
|
+ .rear_fan_ball(rear_ball)
|
|
|
+ );
|
|
|
+
|
|
|
+ // PTC: channels 0..23, active high. Front/Rear: the board adapter maps
|
|
|
+ // the 8 fan bitmap bits (24..31) through FAN_BOARD_INVERT_MASK to balls.
|
|
|
+ assign ptc_pwm_out = logical_bitmap[23:0];
|
|
|
+ assign front_fan_pwm_out = front_ball;
|
|
|
+ assign rear_fan_pwm_out = rear_ball;
|
|
|
+endmodule
|