aboutsummaryrefslogtreecommitdiffstats
path: root/manual/PRESENTATION_ExSyn/memory_02.v
blob: dbe86ed187e5d074cf19f10d36e70c4828742bcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module test(
    input             WR1_CLK,  WR2_CLK,
    input             WR1_WEN,  WR2_WEN,
    input      [7:0]  WR1_ADDR, WR2_ADDR,
    input      [7:0]  WR1_DATA, WR2_DATA,
    input             RD1_CLK,  RD2_CLK,
    input      [7:0]  RD1_ADDR, RD2_ADDR,
    output reg [7:0]  RD1_DATA, RD2_DATA
);

reg [7:0] memory [0:255];

always @(posedge WR1_CLK)
    if (WR1_WEN)
        memory[WR1_ADDR] <= WR1_DATA;

always @(posedge WR2_CLK)
    if (WR2_WEN)
        memory[WR2_ADDR] <= WR2_DATA;

always @(posedge RD1_CLK)
    RD1_DATA <= memory[RD1_ADDR];

always @(posedge RD2_CLK)
    RD2_DATA <= memory[RD2_ADDR];

endmodule
>parameter Y_WIDTH = 0; (* force_downto *) input [A_WIDTH-1:0] A; (* force_downto *) input [B_WIDTH-1:0] B; (* force_downto *) output [Y_WIDTH-1:0] Y; parameter _TECHMAP_CELLTYPE_ = ""; parameter _TECHMAP_CONSTMSK_A_ = 0; parameter _TECHMAP_CONSTVAL_A_ = 0; parameter _TECHMAP_CONSTMSK_B_ = 0; parameter _TECHMAP_CONSTVAL_B_ = 0; function automatic [(1 << `LUT_WIDTH)-1:0] gen_lut; input integer width; input integer operation; input integer swap; input integer sign; input integer operand; integer n, i_var, i_cst, lhs, rhs, o_bit; begin gen_lut = width'b0; for (n = 0; n < (1 << width); n++) begin if (sign) i_var = n[width-1:0]; else i_var = n; i_cst = operand; if (swap) begin lhs = i_cst; rhs = i_var; end else begin lhs = i_var; rhs = i_cst; end if (operation == 0) o_bit = (lhs < rhs); if (operation == 1) o_bit = (lhs <= rhs); if (operation == 2) o_bit = (lhs > rhs); if (operation == 3) o_bit = (lhs >= rhs); gen_lut = gen_lut | (o_bit << n); end end endfunction generate localparam operation = _TECHMAP_CELLTYPE_ == "$lt" ? 0 : _TECHMAP_CELLTYPE_ == "$le" ? 1 : _TECHMAP_CELLTYPE_ == "$gt" ? 2 : _TECHMAP_CELLTYPE_ == "$ge" ? 3 : -1; if (A_WIDTH > `LUT_WIDTH || B_WIDTH > `LUT_WIDTH || Y_WIDTH != 1) wire _TECHMAP_FAIL_ = 1; else if (&_TECHMAP_CONSTMSK_B_) \$lut #( .WIDTH(A_WIDTH), .LUT({ gen_lut(A_WIDTH, operation, 0, A_SIGNED && B_SIGNED, _TECHMAP_CONSTVAL_B_) }) ) _TECHMAP_REPLACE_ ( .A(A), .Y(Y) ); else if (&_TECHMAP_CONSTMSK_A_) \$lut #( .WIDTH(B_WIDTH), .LUT({ gen_lut(B_WIDTH, operation, 1, A_SIGNED && B_SIGNED, _TECHMAP_CONSTVAL_A_) }) ) _TECHMAP_REPLACE_ ( .A(B), .Y(Y) ); else wire _TECHMAP_FAIL_ = 1; endgenerate endmodule