<< Chapter < Page | Chapter >> Page > |
Redesign the PicoBlaze design so that pulse width high and lows can be controlled independently. Perform this task using INPUT instruction and allocating two input registers- one for high pulse and another for low pulse widths. Modify the assembler code accordingly, assemble it, and assign to the ROM table. Run the simulation and observe the pulse output.
INPUT input_high_pw, input_high_port
which reads the high value from the
input_high_port addressThink about what address the registers will be at and how you will decode the address. How will the address be qualified?
;simple example of PWM using picoblaze
;
;Naming ports and assigning values
;
CONSTANT pw_port, 02 ;
CONSTANT input_high_port, 01 ;pulsewidth high value port
CONSTANT input_low_port, 00 ;pulsewidth low value port
;
;Naming registers
;
NAMEREG s01, pw_data ;used to form base of software delay loops
NAMEREG s02, input_high_pw ;register to store pulse width high value
NAMEREG s03, input_low_pw ;register to store pulse width low value
NAMEREG s04, pw_high_delay_reg ;used to form base of software delay loops
NAMEREG s05, pw_low_delay_reg ;used to form base of software delay loops
;
;Start of program and initialisation of displays
;
start LOAD pw_high_delay_reg, 00 ;lets clear the registers
LOAD pw_low_delay_reg, 00 ;lets clear the registers
OUTPUT pw_data, pw_port ;lets set the data to be 0 for now
;read the high and low values
INPUT input_high_pw, input_high_port ;read the high value
LOAD pw_data,00 ;load the register with the data to be output
INPUT input_low_pw, input_low_port ;read the low value
;start the loops
load_values LOAD pw_high_delay_reg, input_high_pw ;load pulse width register
LOAD pw_low_delay_reg, input_low_pw
;do the high pulse width
pw_high_loop SUB pw_high_delay_reg, 01 ;little
JUMP NZ, pw_high_loop ;
XOR pw_data, 01 ;invert the data
OUTPUT pw_data, pw_port ;
;do the low pulse width
pw_low_loop SUB pw_low_delay_reg, 01 ; little
JUMP NZ, pw_low_loop ;
XOR pw_data, 01 ;invert the data
OUTPUT pw_data, pw_port
JUMP load_values; start again
In this lab you learned how to develop a PicoBlaze design by using simple pulse width application. You also learned how to add external registers to the design and pass the information to the program.
Notification Switch
Would you like to follow the 'Xilinx university program: professor workshop' conversation and receive update notifications?