File: smtmap.v

package info (click to toggle)
yosys 0.23-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 20,644 kB
  • sloc: cpp: 138,485; python: 8,605; yacc: 3,451; sh: 2,358; makefile: 1,204; lex: 696; perl: 399; ansic: 371; javascript: 323; tcl: 78; vhdl: 46
file content (28 lines) | stat: -rw-r--r-- 654 bytes parent folder | download | duplicates (2)
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
(* techmap_celltype = "$pmux" *)
module smt_pmux (A, B, S, Y);
	parameter WIDTH = 1;
	parameter S_WIDTH = 1;

	(* force_downto *)
	input [WIDTH-1:0] A;
	(* force_downto *)
	input [WIDTH*S_WIDTH-1:0] B;
	(* force_downto *)
	input [S_WIDTH-1:0] S;
	(* force_downto *)
	output [WIDTH-1:0] Y;

	(* force_downto *)
	wire [WIDTH-1:0] Y_B;

	genvar i, j;
	generate
		(* force_downto *)
		wire [WIDTH*(S_WIDTH+1)-1:0] C;

		assign C[WIDTH-1:0] = A;
		for (i = 0; i < S_WIDTH; i = i + 1)
			assign C[WIDTH*(i+2)-1:WIDTH*(i+1)] = S[i] ? B[WIDTH*(i+1)-1:WIDTH*i] : C[WIDTH*(i+1)-1:WIDTH*i];
		assign Y = C[WIDTH*(S_WIDTH+1)-1:WIDTH*S_WIDTH];
	endgenerate
endmodule