ALU ouptut flags

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

ALU ouptut flags

Tony
Hi, could someone give some pointers on how to implement the output flags for the alu?  Any help much appresiated, it is driving me mad!
Reply | Threaded
Open this post in threaded view
|

Re: ALU ouptut flags

culchie
The output flags are set depending upon the output of the out[16]

Say you had a 2 bit number 00. Can you think of a way of using chip(s) to return a 0 only if both
bits were 0? If you can then you're almost there

For ng, do you know how to output only a selected one bit-wide number from a 16 bit number?
If you don't the appendix on hdl will tell you.
Reply | Threaded
Open this post in threaded view
|

Re: ALU ouptut flags

Tony
Thats the problem, I get an error: "sub bus of an internal node may not be used" when I try to isolate 1bit of the 16bit output bus.  I'll give the appendix a re-read, I've probably got the hdl syntax wrong.  Thanks for the advice.
Reply | Threaded
Open this post in threaded view
|

Re: ALU ouptut flags

jkordani
I am in the same boat as you tony.  It appears that you can not split internal pins.  you have to make a new chip and split the internal pin in your chip on the interface boundary for a sub part.  So far, I have not had to make chips that have not been specified, but for this I am stuck.  Have you had success?  I trust the authors when they say that there is no need to use chips they haven't specified to this point, but maybe I'm taking that too literally.


edit:
SPOILER
The hint for each problem is that you can do this with the output of a part (out[0] = w9, out = out.)
you can use something like this for NG.
You can do the same thing to push output in half to two Or8Way, or just make your own Or16Way.
Reply | Threaded
Open this post in threaded view
|

Re: ALU ouptut flags

rick2047
I was just thinking about your spoiler, but it seems to me pushing out 16 different pins for the or8way is just writing too much of HDL code. Shouldn't HDL be facilitating the process rather than coming in the way?
Reply | Threaded
Open this post in threaded view
|

Re: ALU ouptut flags

Gordon
This post was updated on .
I was frustrated with this as well. I figured it would be easy enough to set ng to the value of out[15] but I couldn't make this work in the simulator.

In the end I figured it out while trying a different approach: using And16(a,b,out) where b was a 16 bit constant bit mask with only the MSB bit set. In trying to make this work I stumbled across the idea that I could use commas to separate not only the inputs or outputs to a chip but also the PARTS of a single input:

    And16(a=out, b[0..15]=true, out=ng);      works as expected, how to set some bits false and one true?
lead to:
    And16(a=out, b[0..14]=false, b[15]=true, out[15]=ng);  Which unexpectedly almost works (This syntax looks like I'm trying to call And16() with a fourth parameter but that doesn't cause an error!) but of course this is redundant and still has a syntax problem with the output pin connection.

In the end all I needed to do was tack on the out[15]=ng part to a prior statement where I was dealing with the 'no' flag. Of course this simultaneously offended my compulsive nature while appealing to my efficient nature!

Seriously though, it is easy to forget you're simulating hardware and not writing software. I found my self asking 'why isn't there an assignment operator so I can just assign ng to the value of out[15]?' when I should have been asking myself 'what connection would I need to make between which out pin and the ng flag pin?'

The second question lead to the solution. The best place to set the ng flag is right after implementing the last input flag. This was very clear when I visualized this as a circuit, and less clear the more I fought the simulator's syntax.

On syntax:

   I must have read through Appendix A 3 times before understanding this mention in one of the examples:

--------------
Example
   CHIP Foo {
     IN in[8] // 8-bit input
     OUT out[8] // 8-bit output
       // Foo's body (irrelevant to the example)
     }


Suppose now that Foo is invoked by another chip using the part statement:
Foo(in[2..4]=v, in[6..7]=true, out[0..3]=x, out[2..6]=y)
---------------


How much clearer this would be if the example instead read:

-----------
   . . .

Foo is typically invoked using the part statement:
Foo(in=v, out=x, out=y)

Suppose now that Foo is invoked by another chip using the part statement:
Foo(in[2..4]=v, in[6..7]=true, out[0..3]=x, out[2..6]=y)

The second example sets individual bits on an input pin as well as assigning two different sets of bits to two output pins.

-------------
Using something other than a comma to indicate multiple bindings would be the best fix here. Failing that, some explanation in prose would go a long way to helping the reader. Breaking the above example into two would help further. A simpler second example could focus solely on extending subscripting to deal with split inputs and outputs.

I'm overall very happy with the course but have on occasion been frustrated by the course materials. The quickest summary I could make of my concerns is: there seems to be a forced economy to the information provided, well beyond what could be justified by desire to keep the text approachable to novice students.

If the authors have any interest I'd be happy to share my specific observations.

Reply | Threaded
Open this post in threaded view
|

Re: ALU ouptut flags

daveking
In reply to this post by Tony
would you mail a implement alu to me ?
Reply | Threaded
Open this post in threaded view
|

Re: ALU ouptut flags

cadet1620
Administrator
daveking wrote
would you mail a implement alu to me ?
If you post specific questions I'll answer them, or you can send me a private message and I'll be happy to guide you through designing your own ALU off forum.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: ALU ouptut flags

daveking
to cadet1620 :
    thanks for your answer. i tried several ways to implement the alu chip but the emluator print errors.
i donn't know how to implement the output flags. The other question is which function will be run when the flag zx and nx is set.
    may i mail my implement of alu to you to and y can check it out for me?
 daveking^^