Base 10 vs Base 2 numbers

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

Base 10 vs Base 2 numbers

polarbearskill
Hello,

I'm beginning to work on the RAM8 chip for chapter 3, however I'm a bit confused about the "address" value in the RAM8.cmp file.

I know I need pass this "address" into the Mux8Way16.hdl chip I created in the first chapter.  However in that file the "sel" pin input was in Base 2 (binary) format, whereas the address data is in base 10.  Does the HDL automatically switch between these two formats?

Thanks in advance,
Chad
Reply | Threaded
Open this post in threaded view
|

Re: Base 10 vs Base 2 numbers

cadet1620
Administrator
polarbearskill wrote
I know I need pass this "address" into the Mux8Way16.hdl chip I created in the first chapter.  However in that file the "sel" pin input was in Base 2 (binary) format, whereas the address data is in base 10.  Does the HDL automatically switch between these two formats?
Short answer: yes.

The address is just a number.  Binary and decimal are just external representations.

In the .cmp and .out files, the choice between binary and decimal is made by the way the .tst scripts are written.  For example, in Mux8Way16.tst you will see
    output-list a%B1.16.1 b%B1.16.1  ...  sel%B1.3.1 out%B1.16.1;
The %B in this line controls the format used to display the values -- in this case, in binary.

in RAM8.tst the outputs are
    output-list time%S1.4.1 in%D1.6.1 load%B2.1.2 address%D3.1.3 out%D1.6.1;
and the %D means decimal.

Values can be set set in the test scripts in various formats, whatever is convenient for the script writer. This causes no change in the behavior of the script's output.

If you are curious, details on the test script language are available in Appendix B.

--Mark