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


Groups > comp.lang.forth > #1159

Re: Verilog macro issue

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!feeder.news-service.com!feeder.news-service.com!hitnews.eu!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date Mon, 11 Apr 2011 14:16:57 -0500
From Chris Hinsley <chris.hinsley@gmail.com>
Newsgroups comp.lang.forth
Date Mon, 11 Apr 2011 20:16:57 +0100
Message-ID <2011041120165770637-chrishinsley@gmailcom> (permalink)
References <2011040219361212758-chrishinsley@gmailcom>
MIME-Version 1.0
Content-Type text/plain; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding 8bit
Subject Re: Verilog macro issue
User-Agent Unison/2.1.4
Lines 23
X-Usenet-Provider http://www.giganews.com
X-Trace sv3-zx4qUASKcjCGYV10ktxEglp8//8TMwGYhERCo+2PpdcbQN3wIjneX+8Rn7p6X5513pp51EvdhiCRKj8!WPtwRP3Vyat5F7jjMTDxI+3K95kU0OgpWzFi8Y5no2Q8XUAtm0lNQd6thlRDMMhauMy0ug==
X-Complaints-To abuse@giganews.com
X-DMCA-Notifications http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Bytes 1517
Xref x330-a1.tempe.blueboxinc.net comp.lang.forth:1159

Show key headers only | View raw


Here's what I ended up with after my chat on the Verilog news group.

Many thanks to Johnathon Bromley for his crash tutoring on Verilog. :)

module enc(i, o);
	parameter OUT_BITS = 2;
	localparam IN_BITS = 1 << OUT_BITS;
	input [IN_BITS-1:0] i;
	output [OUT_BITS-1:0] o;
	reg [OUT_BITS-1:0] o;
	always @(*)
	begin
		integer n;
		o = 0;
		for (n = 0; n < IN_BITS; n += 1)
			if (i[n]) o |= n;
	end
endmodule

This turns into very nice hardware in Quartus.

Chris

Back to comp.lang.forth | Previous | NextPrevious 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