Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #987

Re: Verilog macro issue

From Chris Hinsley <chris.hinsley@gmail.com>
Newsgroups comp.lang.forth
Date 2011-04-03 13:20 +0100
Message-ID <2011040313203492550-chrishinsley@gmailcom> (permalink)
References (1 earlier) <EbGdnVLa4s_15QrQnZ2dnUVZ8mCdnZ2d@brightview.co.uk> <2011040223012056408-chrishinsley@gmailcom> <5dGdnYypo8bZOQrQnZ2dnUVZ8s2dnZ2d@brightview.co.uk> <2011040303581035956-chrishinsley@gmailcom> <2011040312274643418-chrishinsley@gmailcom>
Subject Re: Verilog macro issue

Show all headers | View raw


Hurrah, finally, I managed it. Gee that was tough but educational. !

Thanks Jan for putting me on the path. :)

`define ENCODER(NAME, BITS)  \
module NAME(i, o);  \
	parameter WIDTH = (2 ** BITS);  \
	input [(WIDTH - 1):0] i;  \
	output [(BITS - 1):0] o;  \
	reg [(BITS - 1):0] r;  \
	genvar row;  \
	generate  \
	begin  \
		for (row = 0; row < BITS; row = row + 1)  \
		begin : G  \
			always  \
			begin  \
				integer start;  \
				integer range;  \
				r[row] = 0;  \
				for (start = (2 ** row); start < WIDTH; start = start + (2 ** row) 
+ (2 ** row))  \
				begin  \
					for (range = start; range < (start + (2 ** row)); range = range + 1)  \
					begin  \
						r[row] = (r[row] | i[range]);  \
					end  \
				end  \
			end  \
			assign o[row] = r[row];  \
		end  \
	end  \
	endgenerate  \
endmodule

`ENCODER(enc1, 1)
`ENCODER(enc2, 2)
`ENCODER(enc3, 3)
`ENCODER(enc4, 4)
`ENCODER(enc5, 5)

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Verilog macro issue Chris Hinsley <chris.hinsley@gmail.com> - 2011-04-02 19:36 +0100
  Re: Verilog macro issue Jan Coombs <jan_2011-02@murray-microft.co.uk> - 2011-04-02 20:26 +0100
    Re: Verilog macro issue Chris Hinsley <chris.hinsley@gmail.com> - 2011-04-02 20:31 +0100
      Re: Verilog macro issue Chris Hinsley <chris.hinsley@gmail.com> - 2011-04-02 20:43 +0100
        Re: Verilog macro issue Chris Hinsley <chris.hinsley@gmail.com> - 2011-04-02 21:36 +0100
          Re: Verilog macro issue Chris Hinsley <chris.hinsley@gmail.com> - 2011-04-02 22:12 +0100
    Re: Verilog macro issue Chris Hinsley <chris.hinsley@gmail.com> - 2011-04-02 23:01 +0100
      Re: Verilog macro issue Jan Coombs <jan_2011-02@murray-microft.co.uk> - 2011-04-02 23:33 +0100
        Re: Verilog macro issue Chris Hinsley <chris.hinsley@gmail.com> - 2011-04-03 03:58 +0100
          Re: Verilog macro issue Chris Hinsley <chris.hinsley@gmail.com> - 2011-04-03 12:27 +0100
            Re: Verilog macro issue Chris Hinsley <chris.hinsley@gmail.com> - 2011-04-03 13:20 +0100
              Re: Verilog macro issue Chris Hinsley <chris.hinsley@gmail.com> - 2011-04-07 23:26 +0100
                Re: Verilog macro issue Jan Coombs <jan_2011-02@murray-microft.co.uk> - 2011-04-10 23:20 +0100
              Re: Verilog macro issue rickman <gnuarm@gmail.com> - 2011-04-11 10:36 -0700
  Re: Verilog macro issue Chris Hinsley <chris.hinsley@gmail.com> - 2011-04-11 20:16 +0100

csiph-web