Skip to content

Commit

Permalink
BRAM simulation matching yosys, minor edits to qpsram, brot
Browse files Browse the repository at this point in the history
  • Loading branch information
sylefeb committed Nov 1, 2023
1 parent 254de73 commit de29189
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
4 changes: 3 additions & 1 deletion frameworks/boards/brot/board.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
{"set" : "pmod_com_out", "define" : "PMOD_COM_OUT=1"},
{"set" : "pmod_com_in", "define" : "PMOD_COM_IN=1"},
{"set" : "parallel_screen", "define" : "PARALLEL_SCREEN=1"},
{"set" : "qpsram", "define" : "QPSRAM=1"}
{"set" : "qpsram", "define" : "QPSRAM=1"},
{"set" : "sync_in", "define" : "SYNC_IN=1"},
{"set" : "sync_out", "define" : "SYNC_OUT=1"}
],
"builders": [
{
Expand Down
13 changes: 13 additions & 0 deletions frameworks/boards/brot/brot.v
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ module top(
inout PMOD_A8,
inout PMOD_A9,
output PMOD_A10,
`endif
`ifdef SYNC_IN
input PMOD_A1,
`endif
`ifdef SYNC_OUT
output PMOD_B9,
`endif
input CLK_48
);
Expand Down Expand Up @@ -230,6 +236,12 @@ M_main __main(
.out_uart_tx(GPIO0),
.in_uart_rx(GPIO1),
`endif
`ifdef SYNC_IN
.in_sync(PMOD_A1),
`endif
`ifdef SYNC_OUT
.out_sync(PMOD_B9),
`endif
// -----------------------------------------------------------------------------
/*
PMOD com wiring:
Expand Down Expand Up @@ -265,5 +277,6 @@ PMOD_A8 is on a global buffer on the 'in fpga' and has to be used for the clock
`endif
.in_run(run_main)
);
// -----------------------------------------------------------------------------

endmodule
4 changes: 3 additions & 1 deletion frameworks/boards/icarus/icarus.v
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(header_2_M)
*/
`define ICARUS 1
`define ICARUS 1
`define SIMULATION 1

$$ICARUS = 1
$$SIMULATION = 1
$$NUM_LEDS = 8
Expand Down
1 change: 1 addition & 0 deletions frameworks/boards/verilator/verilator.v
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
`define VERILATOR 1
`define COLOR_DEPTH 6
`define SDRAM_WORD_WIDTH 16
`define SIMULATION 1

$$VERILATOR = 1
$$NUM_LEDS = 8
Expand Down
25 changes: 19 additions & 6 deletions frameworks/templates/bram_generic.v.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,25 @@ input [%ADDR_WIDTH%-1:0] in_addr,
output reg %DATA_TYPE% [%DATA_WIDTH%-1:0] out_rdata,
input clock
);
(* no_rw_check *) reg %DATA_TYPE% [%DATA_WIDTH%-1:0] buffer[%DATA_SIZE%-1:0];
always @(posedge clock) begin
if (in_wenable) begin
buffer[in_addr] <= in_wdata;
(* no_rw_check *) reg %DATA_TYPE% [%DATA_WIDTH%-1:0] buffer[%DATA_SIZE%-1:0];
`ifdef SIMULATION
// in simulation we use a different code that matches yosys output with
// no_rw_check enabled (which we use to preserve compact LUT designs)
always @(posedge clock) begin
if (in_wenable) begin
buffer[in_addr] <= in_wdata;
out_rdata <= in_wdata;
end else begin
out_rdata <= buffer[in_addr];
end
end
out_rdata <= buffer[in_addr];
end
`else
always @(posedge clock) begin
if (in_wenable) begin
buffer[in_addr] <= in_wdata;
end
out_rdata <= buffer[in_addr];
end
`endif
%INITIAL%
endmodule

0 comments on commit de29189

Please sign in to comment.