Line 46... |
Line 46... |
|
|
The computer compiler uses an architectural description of the processor stating
|
The computer compiler uses an architectural description of the processor stating
|
the sizes of the instruction memory, data stack, and return stack; the input and
|
the sizes of the instruction memory, data stack, and return stack; the input and
|
output ports; RAM and ROM types and sizes; and peripherals.
|
output ports; RAM and ROM types and sizes; and peripherals.
|
|
|
The instructions are all single-cycle. The instructions include
|
The instructions are all single-cycle. The instructions are:
|
- 4 arithmetic instructions: addition, subtraction, increment, and decrement
|
- 4 arithmetic instructions: addition, subtraction, increment, and decrement
|
- 2 carry bit instructions: +c and -c for addition and subtraction respectively
|
- 2 carry bit instructions: +c and -c for addition and subtraction respectively
|
- 3 bit-wise logical instructions: and, or, and exclusive or
|
- 3 bit-wise logical instructions: and, or, and exclusive or
|
- 7 shift and rotation instructions: <<0, <<1, 0>>, 1>>, <>msb, and >>lsb
|
- 7 shift and rotation instructions: <<0, <<1, 0>>, 1>>, <>, and lsb>>
|
- 4 logical instructions: 0=, 0<>, -1=, -1<>
|
- 4 logical instructions: 0=, 0<>, -1=, -1<>
|
- 6 Forth-like data stack instructions: drop, dup, nip, over, push, swap
|
- 6 Forth-like data stack instructions: drop, dup, nip, over, push, swap
|
- 3 Forth-like return stack instructions: >r, r>, r@
|
- 3 Forth-like return stack instructions: >r, r>, r@
|
- 2 input and output
|
- 2 I/O: inport, outport
|
- 6 memory read and write with optional address post increment and post decrement
|
- 6 memory read and write with optional address post increment and post decrement
|
- 2 jump and conditional jump
|
- 2 jump and conditional jump
|
- 2 call and conditional call
|
- 2 call and conditional call
|
- 1 function return
|
- 1 function return
|
- 1 nop
|
- 1 nop
|
Line 88... |
Line 88... |
bugs.
|
bugs.
|
|
|
|
|
SPEED AND RESOURCE UTILIZATION
|
SPEED AND RESOURCE UTILIZATION
|
================================================================================
|
================================================================================
|
|
|
These device speed and resource utilization results are copied from the build
|
These device speed and resource utilization results are copied from the build
|
tests. The full results are listed in the core/9x8/build directories. The
|
tests. The full results are listed in the core/9x8/build directories. The
|
tests use a minimal processor implementation (clock, reset, and one output).
|
tests use a minimal processor implementation (clock, reset, and one output).
|
Device-specific scripts state how these performance numbers were obtained.
|
Device-specific scripts state how these performance numbers were obtained.
|
|
|
Line 597... |
Line 598... |
|
|
The "nop" in the first conditional call prevents the conditional from being
|
The "nop" in the first conditional call prevents the conditional from being
|
dropped from the data stack so that it can be used by the subsequent conditional
|
dropped from the data stack so that it can be used by the subsequent conditional
|
function call.
|
function call.
|
|
|
|
The input from a set-reset INPORT is a pure flag. I.e., either all of the bits
|
|
are zero or all of the bits are one. This can be used as part of executing a
|
|
loop a fixed number of times. For example, the inperiod argument of the
|
|
servo_motor peripheral can be used to receive a strobe every time the PWM goes
|
|
high. The following loop will wait for 10 occurrences of the rising edge of the
|
|
servo_motor PWM before proceeding to the next block of code:
|
|
|
|
10 :loop .inport(I_INPERIOD) + .jumpc(loop,nop) drop
|
|
|
|
|
PERIPHERAL
|
PERIPHERAL
|
================================================================================
|
================================================================================
|
|
|
Peripherals are implemented via Python modules. For example, an open drain I/O
|
Peripherals are implemented via Python modules. For example, an open drain I/O
|
Line 650... |
Line 660... |
latch latch wide inputs for sampling
|
latch latch wide inputs for sampling
|
monitor_stack simulation diagnostic (see below)
|
monitor_stack simulation diagnostic (see below)
|
open_drain for software-implemented I2C buses or similar
|
open_drain for software-implemented I2C buses or similar
|
outFIFO_async output FIFO with an asynchronous read clock
|
outFIFO_async output FIFO with an asynchronous read clock
|
PWM_8bit PWM generator with an 8-bit control
|
PWM_8bit PWM generator with an 8-bit control
|
|
servo_motor PWM modulation suitable for servo motor or similar control
|
|
stepper_motor stepper motor controller with acceleration
|
timer timing for polled loops or similar
|
timer timing for polled loops or similar
|
trace simulation diagnostic (see below)
|
trace simulation diagnostic (see below)
|
UART bidirectional UART
|
UART bidirectional UART
|
UART_Rx receive UART
|
UART_Rx receive UART
|
UART_Tx transmit UART
|
UART_Tx transmit UART
|
Line 1069... |
Line 1081... |
${(size['o_big']+7)/8-1} :loop 0 .outport(O_BIG) .jumpc(loop,1-) drop
|
${(size['o_big']+7)/8-1} :loop 0 .outport(O_BIG) .jumpc(loop,1-) drop
|
|
|
|
|
MACROS
|
MACROS
|
================================================================================
|
================================================================================
|
|
|
There are 3 types of macros used by the assembler.
|
There are 3 types of macros used by the assembler.
|
|
|
The first kind of macros are built in to the assembler and are required to
|
The first kind of macros are built in to the assembler and are required to
|
encode instructions that have embedded values or have mandatory subsequent
|
encode instructions that have embedded values or have mandatory subsequent
|
instructions. These include function calls, jump instructions, function return,
|
instructions. These include function calls, jump instructions, function return,
|
Line 1151... |
Line 1164... |
conflicts with a built-in macro.
|
conflicts with a built-in macro.
|
|
|
|
|
CONDITIONAL COMPILATION
|
CONDITIONAL COMPILATION
|
================================================================================
|
================================================================================
|
The computer compiler and assembler recognize conditional compilation as
|
|
follows: .IFDEF, .IFNDEF, .ELSE, and .ENDIF can be used in the architecture
|
|
file and they can be used to conditionally include functions, files, etc within
|
|
the assembly code; .ifdef, .ifndef, .else, and .endif can be used in function
|
|
bodies, variable bodies, etc. to conditionally include assembly code, symbols,
|
|
or data. Conditionals cannot cross file boundaries.
|
|
|
|
The computer compiler examines the list of defined symbols such as I/O ports,
|
|
I/O signals, etc. to evaluate the true/false condition associated with the
|
|
.IFDEF and .IFNDEF commands. The "-D" option to the computer compiler is
|
|
provided to define symbols for enabling conditionally compiled configuration
|
|
commands. Similarly, the assembler examines the list of I/O ports, I/O signals,
|
|
parameters, constants, etc. to evaluate the .IFDEF, .IFNDEF, .ifdef, and .ifndef
|
|
conditionals.
|
|
|
|
For example, a diagnostic UART can be conditionally included using the
|
Conditional compilation is accepted in the architecture file and in the assembly
|
configuration commands:
|
source files and is based on whether or not the referenced symbol is defined.
|
|
|
|
In the architecture file, symbols are defined by CONSTANT, INPORT, OUTPORT, and
|
|
PERIPHERAL statements, or by the "-D D_name" argument to ssbcc. The line
|
|
|
|
.IFDEF name
|
|
|
|
.ENDIF
|
|
|
|
will then include the lines "" if the symbol "name" is defined.
|
|
The ".IFNDEF" command is similar except that the statements included if the
|
|
symbol is not defined. A ".ELSE" is also provided.
|
|
|
|
In an assembly file directives are conditionally included using the .IFDEF and
|
|
.IFNDEF directives, an optional .ELSE directive, and the terminating .ENDIF
|
|
directive. Note that this is done at the directive level, i.e. function
|
|
declarations, memory declarations, and so forth. Within a function code is
|
|
conditionally included starting with a ".ifdef(name)" or a ".ifndef(name)", an
|
|
optional ".else" and a terminating ".endif".
|
|
|
|
For example, a diagnostic UART can be conditionally included in a program by
|
|
including the following lines in the architecture file:
|
|
|
.IFDEF ENABLE_UART
|
.IFDEF D_ENABLE_UART
|
PORTCOMMENT Diagnostic UART
|
PORTCOMMENT Diagnostic UART
|
PERIPHERAL UART_Tx outport=O_UART_TX ...
|
PERIPHERAL UART_Tx outport=O_UART_TX ...
|
.ENDIF
|
.ENDIF
|
|
|
And the assembly code can include conditional code fragments such the following,
|
A "uart_tx" function can be optionally created using code similar to the
|
where the existence of the output port is used to determine whether or not to
|
following. Note that the symbol for the .outport macro is used to determine
|
send a character to that output port:
|
whether or not the function is defined since that is more closely related to
|
|
whether or not the function can be defined. The function definition must
|
.ifdef(O_UART_TX) 'A' .outport(O_UART_TX) .endif
|
preceed any ".ifdef(uart_tx)" conditionals used to output diagnostics.
|
|
|
Invoking the computer compiler with "-D ENABLE_UART" will generate a module with
|
.IFDEF O_UART_TX
|
the UART peripheral and will enable the conditional code sending the 'A'
|
.function uart_tx
|
character to the UART port.
|
:loop .outport(O_UART_TX) .jumpc(loop,nop) .return(drop)
|
|
.ENDIF
|
|
|
|
Diagnostics in the assembly code can be included using either
|
|
|
|
.ifdef(D_ENABLE_UART) N"Msg\r\n" .call(uart_tx) .endif
|
|
|
|
or
|
|
|
|
.ifdef(uart_tx) N"Msg\r\n" .call(uart_tx) .endif
|
|
|
|
Conditional compilation cannot cross file boundaries.
|
|
|
|
The assembler also recognizes the ".define" directive. For example, specific
|
|
diagnostics could be enabled if the UART is instantiated as follows:
|
|
|
|
.IFDEF O_UART_TX
|
|
.define D_DEBUG_FUNCTION_A
|
|
.ENDIF
|
|
|
|
...
|
|
|
|
.ifdef(D_DEBUG_FUNCTION_A) N"Debug Msg\r\n" .call(uart_tx) .endif
|
|
|
The following code can be used to preclude multiple attempted inclusions of an
|
The following code illustrates how to preclude multiple attempted inclusions of
|
assembly library file.
|
an assembly library file.
|
|
|
; put these two lines near the top of the file
|
; put these two lines near the top of the file
|
.IFNDEF C_FILENAME_INCLUDED
|
.IFNDEF D_FILENAME_INCLUDED
|
.constant C_FILENAME_INCLUDED 1
|
.define D_FILENAME_INCLUDED
|
; put the library body here
|
; put the library body here
|
...
|
...
|
; put this line at the bottom of the file
|
; put this line at the bottom of the file
|
.ENDIF ; .IFNDEF C_FILENAME_INCLUDED
|
.ENDIF ; .IFNDEF D_FILENAME_INCLUDED
|
|
|
The ".INCLUDE" configuration command can be used to read configuration commands
|
The ".INCLUDE" configuration command can be used to read configuration commands
|
from additional sources.
|
from additional sources. For example, the following code will conditionally
|
|
include a general UART library if the outport O_UART_TX is defined:
|
|
|
|
.IFDEF O_UART_TX
|
|
.INCLUDE uart.s
|
|
.ENDIF
|
|
|
|
|
SIMULATIONS
|
SIMULATIONS
|
================================================================================
|
================================================================================
|
|
|
Line 1274... |
Line 1321... |
incomplete. The output HDL is currently restricted to Verilog although a VHDL
|
incomplete. The output HDL is currently restricted to Verilog although a VHDL
|
package file is automatically generated by the computer compiler.
|
package file is automatically generated by the computer compiler.
|
|
|
The "INVERT_RESET" configuration command is used to indicate an active-low reset
|
The "INVERT_RESET" configuration command is used to indicate an active-low reset
|
is input to the micro controller rather than an active-high reset.
|
is input to the micro controller rather than an active-high reset.
|
|
|
A VHDL package file is automatically generated by the computer compiler.
|
|