aboutsummaryrefslogtreecommitdiffstats
path: root/techlibs/xilinx/tests/bram1.v
blob: ac7140a04438cf16580ec8656fc029ad4adf76b2 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
module bram1 #(
	parameter ABITS = 8, DBITS = 8, TRANSP = 0
) (
	input clk,

	input [ABITS-1:0] WR_ADDR,
	input [DBITS-1:0] WR_DATA,
	input WR_EN,

	input [ABITS-1:0] RD_ADDR,
	output [DBITS-1:0] RD_DATA
);
	localparam [ABITS-1:0] INIT_ADDR_0 = 1234;
	localparam [ABITS-1:0] INIT_ADDR_1 = 4321;
	localparam [ABITS-1:0] INIT_ADDR_2 = 2**ABITS-1;
	localparam [ABITS-1:0] INIT_ADDR_3 = (2**ABITS-1) / 2;

	localparam [DBITS-1:0] INIT_DATA_0 = 128'h 51e152a7300e309ccb8cd06d34558f49;
	localparam [DBITS-1:0] INIT_DATA_1 = 128'h 07b1fe94a530ddf3027520f9d23ab43e;
	localparam [DBITS-1:0] INIT_DATA_2 = 128'h 3cedc6de43ef3f607af3193658d0eb0b;
	localparam [DBITS-1:0] INIT_DATA_3 = 128'h f6bc5514a8abf1e2810df966bcc13b46;

	reg [DBITS-1:0] memory [0:2**ABITS-1];
	reg [ABITS-1:0] RD_ADDR_BUF;
	reg [DBITS-1:0] RD_DATA_BUF;

	initial begin
		memory[INIT_ADDR_0] <= INIT_DATA_0;
		memory[INIT_ADDR_1] <= INIT_DATA_1;
		memory[INIT_ADDR_2] <= INIT_DATA_2;
		memory[INIT_ADDR_3] <= INIT_DATA_3;
	end

	always @(posedge clk) begin
		if (WR_EN) memory[WR_ADDR] <= WR_DATA;
		RD_ADDR_BUF <= RD_ADDR;
		RD_DATA_BUF <= memory[RD_ADDR];
	end

	assign RD_DATA = TRANSP ? memory[RD_ADDR_BUF] : RD_DATA_BUF;
endmodule
/span> Description [This procedure compiles into a stand-alone program for DAG-aware rewriting of the AIGs. A BLIF or PLA file to be considered for rewriting should be given as a command-line argument. Implementation of the rewriting is inspired by the paper: Per Bjesse, Arne Boralv, "DAG-aware circuit compression for formal verification", Proc. ICCAD 2004.] SideEffects [] SeeAlso [] ***********************************************************************/ int main( int argc, char * argv[] ) { // parameters int fUseResyn2 = 0; int fPrintStats = 1; int fVerify = 1; // variables Abc_Frame_t * pAbc; char * pFileName; char Command[1000]; clock_t clkRead, clkResyn, clkVer, clk; ////////////////////////////////////////////////////////////////////////// // get the input file name if ( argc != 2 ) { printf( "Wrong number of command-line arguments.\n" ); return 1; } pFileName = argv[1]; ////////////////////////////////////////////////////////////////////////// // start the ABC framework Abc_Start(); pAbc = Abc_FrameGetGlobalFrame(); clk = clock(); ////////////////////////////////////////////////////////////////////////// // read the file sprintf( Command, "read %s", pFileName ); if ( Cmd_CommandExecute( pAbc, Command ) ) { fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); return 1; } ////////////////////////////////////////////////////////////////////////// // balance sprintf( Command, "balance" ); if ( Cmd_CommandExecute( pAbc, Command ) ) { fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); return 1; } clkRead = clock() - clk; ////////////////////////////////////////////////////////////////////////// // print stats if ( fPrintStats ) { sprintf( Command, "print_stats" ); if ( Cmd_CommandExecute( pAbc, Command ) ) { fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); return 1; } } clk = clock(); ////////////////////////////////////////////////////////////////////////// // synthesize if ( fUseResyn2 ) { sprintf( Command, "balance; rewrite -l; refactor -l; balance; rewrite -l; rewrite -lz; balance; refactor -lz; rewrite -lz; balance" ); if ( Cmd_CommandExecute( pAbc, Command ) ) { fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); return 1; } } else { sprintf( Command, "balance; rewrite -l; rewrite -lz; balance; rewrite -lz; balance" ); if ( Cmd_CommandExecute( pAbc, Command ) ) { fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); return 1; } } clkResyn = clock() - clk; ////////////////////////////////////////////////////////////////////////// // print stats if ( fPrintStats ) { sprintf( Command, "print_stats" ); if ( Cmd_CommandExecute( pAbc, Command ) ) { fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); return 1; } } ////////////////////////////////////////////////////////////////////////// // write the result in blif sprintf( Command, "write_blif result.blif" ); if ( Cmd_CommandExecute( pAbc, Command ) ) { fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); return 1; } ////////////////////////////////////////////////////////////////////////// // perform verification clk = clock(); if ( fVerify ) { sprintf( Command, "cec %s result.blif", pFileName ); if ( Cmd_CommandExecute( pAbc, Command ) ) { fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); return 1; } } clkVer = clock() - clk; printf( "Reading = %6.2f sec ", (float)(clkRead)/(float)(CLOCKS_PER_SEC) ); printf( "Rewriting = %6.2f sec ", (float)(clkResyn)/(float)(CLOCKS_PER_SEC) ); printf( "Verification = %6.2f sec\n", (float)(clkVer)/(float)(CLOCKS_PER_SEC) ); ////////////////////////////////////////////////////////////////////////// // stop the ABC framework Abc_Stop(); return 0; }