forked from johan92/yafpgatetris
-
Notifications
You must be signed in to change notification settings - Fork 0
Modifications made
Konstantin edited this page May 15, 2018
·
3 revisions
This project purpose is to modify and adapt yafpgatetris code to make it friendly to current version of Yosys framework. Below is a description of major modifications we had to implement.
Most modifications refer to lack of support for multi-dimentional and composite data types in Yosys. One and only multi-dimentional data type supported should be written like this:
reg [3:0] mem [0:15] [0:15];
always @(posedge clk) begin
y <= mem[a][b];
mem[a][b] <= c;
end
This memory type is very restrictive. Particularly, memories can't be sliced. This forced us to flatten almost all SystemVerilog packed arrays to one-dimentional Verilog-style vectors. That is not a rewarding job.
Limited support for multi-dimentional and composite data types decreases relevance of using Yosys for larger projects.
typedef enum { EV_LEFT,
EV_RIGHT,
EV_DOWN,
EV_ROTATE,
EV_NEW_GAME } user_event_t;
changed to
// user_events
`define EV_DOWN 3'b000
`define EV_RIGHT 3'b001
`define EV_LEFT 3'b010
`define EV_ROTATE 3'b011
`define EV_NEW_GAME 3'b100
typedef struct packed {
logic [3:0][0:3][0:3] data;
logic [`TETRIS_COLORS_WIDTH-1:0] color;
logic [1:0] rotation;
logic signed [`FIELD_COL_CNT_WIDTH:0] x;
logic signed [`FIELD_ROW_CNT_WIDTH:0] y;
} block_info_t;
changed to
// next block info
logic [4*4*4-1:0] next_block_data;
logic [`TETRIS_COLORS_WIDTH-1:0] next_block_color;
logic [1:0] next_block_rotation;
logic signed [`FIELD_COL_CNT_WIDTH:0] next_block_x;
logic signed [`FIELD_ROW_CNT_WIDTH:0] next_block_y;
field_clean = '0;
changed to
field_clean = 0;
for( integer row = 0; row < `FIELD_EXT_ROW_CNT; row++ ) begin
for( integer col = 0; col < `FIELD_EXT_COL_CNT; col++ ) begin
changed to
integer row;
integer col;
for( row = 0; row < `FIELD_EXT_ROW_CNT; row = row+1 ) begin
for( col = 0; col < `FIELD_EXT_COL_CNT; col = col+1 ) begin
bcd_o[ (bcd*4+3):(bcd*4+0) ] += 4'd3;
changed to
bcd_o[ (bcd*4+3):(bcd*4+0) ] += bcd_o[ (bcd*4+3):(bcd*4+0) ] + 4'd3;