Latest commit

History

195 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Reflet microcontroller

A micro-controller based on a Reflet CPU.

Part of the system are included as submodules, so you should run git submodule update --init --recursive after cloning this repository.

The CPU

The CPU is a Reflet CPU. More information and the toolchain can be found here: https://github.com/Arkaeriit/reflet.

Peripherals

All the Verilog files describing the peripherals and their submodules are in the peripheral folder.

All the peripherals are controlled and monitored with 8-bits registers to make them compatible with any Reflet CPU. Each register is only accessible with its exact address (even in 16-bit mode, editing the register at address 0xFF00 will not impact the register at address 0xFF01).

The peripherals are identified with a base address and are controlled by editing the register from the base address and a few bytes forwards. For example, with the 16-bit controller, the GPIO got 0xFF07 as its base address and is configured with the register at address 0xFF07 to 0xFF11.

To minimize the synthesis time and size of a reflet microcontroller, peripherals can be enabled or disabled with Verilog parameters.

Hardware info

This peripheral is always active. It is used to read the frequency of the system clock and which peripherals are enabled or not.

Offset with base addressTypeRegister nameEffect
0roclk_lsbContain the 8 LSB of the frequency of the main clock in MHz.
1roclk_msbContain the 8 MSB of the frequency of the main clock in MHz.
2roperiph_1Bits 0 to 2 contain info about the wordsize of the processor. 1 means that it is an 8-bit processor, 2 means a 16 bit, 3 32 bits, 4 64 bits, 5 128 bits, and 0 means any other wordsize. Bit 3 tells if the interrupt multiplexer is enabled. Bit 4 tells if the GPIO is enabled. Bit 5 tells if the timer is enabled. Bit 6 tells if the second timer is enabled. Finally, bit 7 tells if the UART is enabled.
3roperiph_2Bit 0 tells if the PWM is enabled. Bit 1 tells if the seven-segment controller is enabled. Bit 2 tells if the power manager is enabled. Bit 3 tells if the synthesizer is enabled. Bit 4 tells if the extended io is enabled. Bits 5 to 7 are left to 0.

Interrupt multiplexer

The CPU got only 4 interrupt lines, but more than 4 peripherals can raise interrupts. This module lets the user control which peripherals can use interrupts and the priority of each interrupt.

Offset with base addressTypeRegister nameEffect
0r/wint_enBit 0 control if the interrupt from the GPIO is enabled. Bit 1 control if the interrupt from the UART is enabled. Bit 2 control if the interrupt from the timer is enabled. Bit 3 control if the interrupt from timer 2 is enabled.
1r/wint_levelBits 0 and 1 control the priority of the GPIO interrupt. Bits 2 and 3 control the priority of the UART interrupt. Bits 4 and 5 control the priority of the timer interrupt. Bits 6 and 7 control the priority of the timer 2 interrupt.
2roreservedReserved for future used. Locked to 0 for now.
3r/wstatusThis register tells which interrupts are currently raised. Whenever a new interrupt appends, the related bit is raised to 1. To acknowledge the interrupt, its bit must be switched back to 0. Bit 0 tell the state of the GPIO interrupt. Bit 1 tells the state of the UART interrupt. Bit 2 tells the state of the timer interrupt. Bit 3 tells the state of the timer 2 interrupt.

GPIO

The most basic way to interact with the external world. It is made of a 16 bits parallel output and a 16 bits parallel input. The input can trigger an interrupt on the rising or falling edges of each input pin.

Offset with base addressTypeRegister nameEffect
0r/wgpo_lsbControl the 8 first pins of the parallel output.
1r/wgpo_msbControl the 8 last pins of the parallel output.
2rogpi_lsbContain the state of the 8 first pins of the parallel input.
3rogpi_msbContain the state of the 8 last pins of the parallel input.
4r/wrise_int_lsbControl which of the 8 first pins of the parallel input should raise an interrupt on a rising edge.
5r/wrise_int_msbControl which of the 8 last pins of the parallel input should raise an interrupt on a rising edge.
6r/wfall_int_lsbControl which of the 8 first pins of the parallel input should raise an interrupt on a falling edge.
7r/wfall_int_msbControl which of the 8 last pins of the parallel input should raise an interrupt on a falling edge.

Timer

A 24 bits timer. This timer contains two prescalers (pre1 and pre2) and the main counter (mcnt). Each of these 3 values is on 8 bits. The timer raise an interrupt each (pre1 + 1) * (pre2 + 1) * (mcnt) cycles of the system clock.

Offset with base addressTypeRegister nameEffect
0r/wpre1Control the value of pre1.
1r/wpre2Control the value of pre2.
2r/wmcntControl the value of mcnt.

Timer 2

A 23 bits timer. This timer behaves in a similar way to the main timer except that pre1 is on 7 bits instead of 8 and that we can select to use either the system clock or the output of the main timer as the input source. This makes it possible to chain timer and timer2 to have a resulting 47 bits timer.

Offset with base addressTypeRegister nameEffect
0r/wpre1Bit 0 should be set to 0 to use the system clock as an input source and set to 1 to use timer 1 as the input source. Bits 1 to 7 control the value of pre1.
1r/wpre2Control the value of pre2.
2r/wmcntControl the value of mcnt.

UART

A UART module with a baud rate locked at 9600. Its behavior is very similar to the IO functions of the Reflet simulator. To send a message, write its value in the tx_data register and put a 0 in tx_cmd. To receive a message, either enable the interrupt in the interrupt multiplexer or wait for the value in the rx_cmd register to be set to 0. The data will then be readable in the rx_data register.

Offset with base addressTypeRegister nameEffect
0r/wtx_cmdSet to 0 to send a message.
1r/wtx_dataWrite here the message to send.
2r/wrx_cmdThis register is automatically set to 0 when a byte is received.
3r/wrx_dataThe byte received is readable here.

PWM

A PWM module with up to 8 bits of resolution. Its frequency is configurable but the higher the frequency, the smaller the resolution. Its period is controllable with the freq register and its duty cycle with the duty register. The resulting duty cycle will be duty/freq.

Offset with base addressTypeRegister nameEffect
0r/wfreqSet the period of the PWM.
1r/wdutySet the duty-cycle.

Seven segments display controller

Even if this could be done with GPIO and a timer, a controller for seven segments display could be useful. This module is made to control 4 digits displays with colons and dots. In the selection bits, a 1 indicates that the digit is active. In the segments bits, 0 indicates that the segments must be lit.

Offset with base addressTypeRegister nameEffect
0r/wctrlBit 0 is used to enable or disable the display. Bit 1 is used to enable the colon. Bits 4 to 7 are used to select which dots must be turned on. Bits 2 and 3 are unused.
1r/wnum01Bits 0 to 3 are used to set the value of the first number. Bits 4 to 7 are used to set the value of the second number.
2r/wnum23Bits 0 to 3 are used to set the value of the third number. Bits 4 to 7 are used to set the value of the fourth number.

Power manager

This module is meant to either reduce the speed of the processor or disable it until an interrupt happens. To reduce the speed, a PWM signal is sent to the enable pin of the CPU.

Offset with base addressTypeRegister nameEffect
0r/wsleepWhen bit 0 is set to 1, the processor is disabled until a detected interrupt is raised. When bit 1 is set to 1, the processor is slowed down by a factor controlled in the power register. Bits 2 and 3 are unused. Bit 4 to 7 are used to tell if interrupts 0 to 3 are watched. If bit 4 is set to 1, the module will watch for interrupt 0 and unlock the processor if interrupt 0 is raised. Bit 5 will enable interrupt 1 and so on.
1r/wpowerThis register will let you choose the duty cycle to send to the enable pin of the CPU. The duty cycle is (the content of this register + 1)/256.

Frequency synthesizer

The documentation will come when the module will be done

Extended IO

If you need more than the 16 inputs and 16 outputs of the GPIO module, you can use this one to have up to 256 additional inputs and 256 output. The IOs can be selected with an address on a register and controlled with the other one. The inputs can not raise interrupt. The actual number of IO is chosen with a parameter of the controller module.

Offset with base addressTypeRegister nameEffect
0r/waddressSelect which IO is selected.
1r/wcontrolBit 0 contains the value in the selected input. Bit 1 contains the actual value of the selected output. To set the output, write the value you want in bit 2 and set bit 3 to 1. Bits 4 to 7 are unused.

Debug Helper

This module helps in debugging by printing over an UART line the content of the working register whenever a debug instruction is encountered. The data is sent at 9600 bauds in a little-endian fashion. When sending those data, the CPU is disabled to ensure that no debug instructions will be missed.

Controllers

The folder controller contains files used to make 8 bits or a 16 bits microcontroller with a Reflet CPU. As of now, for the 8-bit controller, you must copy the reflet_?bits_controller.v file and replace the data memory with a ROM with a valid Reflet program. For the 16-bit one, you can do so or choose to use the included bootloader instead.

8 bits controller

The 8 bits controller is very limited by its addressable space and thus, is only equipped with a limited amount of peripherals.

The memory map is the following:

StartEndContent
0x000x7FInstructions
0x800xECData
0xED0xFFPeripherals
----------------
0xED0xF0Interrupt multiplexer
0xF10xF8GPIO
0xF90xFBTimer
0xFC0xFFUART

Top-level module

The top-level module is in the controller folder and is named reflet_8bit_controller. It can not be used as-is because there is no way to fill its instruction memory. To use it, you must copy the top-level module and replace the mem_inst module with a ROM.

The parameters for this module are the following:

NameDescriptionDefault value
clk_freqThe frequency of the main clock in Hertz.1 000 000
debug_outputWhen set to 1, enable the debug helper module.0
enable_interrupt_muxIf equal to 0, the interrupt multiplexer is disabled.1
enable_gpioIf equal to 0, the GPIOs are disabled.1
enable_timerIf equal to 0, the timer is disabled.1
enable_uartIf equal to 0, the UART is disabled.1
mem_resetableIf not set to 0, the memories are reset to 0 when the reset signal is pulled down. This can be incompatible with some FPGA's memory blocks.0

The ports of this module are the following:

NameTypeDescription
clkinputThe main clock.
resetinputReset the controller when flipped to low.
debugoutputTurned on for a clock cycle when the CPU executes a debug instruction.
debug_txoutputWhen debug_output is enabled, this line prints the content of the working register on debug instructions.
quitoutputIs turned on from the moment the CPU executes a quit instruction and stops itself.
gpi16-bit inputThe input of the GPIO.
gpo16-bit outputThe output of the GPIO.
rxinputThe rx line of the UART.
txoutputThe tx line of the UART.

16 bits controller

The 16 bits controller is equipped with all the peripherals and its bigger addressable space makes it way easier to program for.

The memory map is the following:

StartEndContent
0x00000x7CFFInstructions
0x7D000x7FFFBootloader
0x80000xFEFFData
0xFF000xFFFFPeripherals
-------------------
0xFF000xFF03Hardware info
0xFF040xFF07Interrupt multiplexer
0xFF080xFF0FGPIO
0xFF100xFF12Timer
0xFF130xFF15Timer 2
0xFF160xFF19UART
0xFF1A0xFF1BPWM
0xFF1C0xFF1ESeven segments controller
0xFF1F0xFF20Power manager
0xFF210xFF21Frequency synthesizer
0xFF220xFF23Extended IO

Top-level module

The top-level module is in the controller folder and is named reflet_16bit_controller. Unlike its 8-bit counterpart, it can be used on its own as it is equipped with a bootloader that can be used to load a program in the data memory. Of course, if it is needed to only use a single program with an implementation, the mem_inst module can be replaced with a ROM.

The parameters for this module are the following:

NameDescriptionDefault value
clk_freqThe frequency of the main clock in Hertz.1 000 000
debug_outputWhen set to 1, enable the debug helper module.0
enable_interrupt_muxIf equal to 0, the interrupt multiplexer is disabled.1
enable_gpioIf equal to 0, the GPIOs are disabled.1
enable_timerIf equal to 0, the timer is disabled.1
enable_timer2If equal to 0, the timer2 is disabled.1
enable_uartIf equal to 0, the UART is disabled.1
enable_pwmIf equal to 0, the PWM is disabled.1
enable_segmentsIf equal to 0, the seven segments display controller is disabled.1
enable_power_managerIf equal to 0, the power manager is disabled.1
enable_synthIf equal to 0, the frequency synthesizer is disabled.1
enable_ext_ioIf equal to 0, the extended IO is disabled.1
data_sizeSize in bytes of the data memory.100
inst_sizeSize in bytes of the instruction memory.128
mem_resetableIf not set to 0, the memories are reset to 0 when the reset signal is pulled down. This can be incompatible with some FPGA's memory blocks.0
ext_io_sizeThe size of the extended io ports.128
swift_bootloaderUse a 50 ms bootloader timeout instead of 4 s.0

The ports of this module are the following:

NameTypeDescription
clkinputThe main clock.
resetinputReset the controller when flipped to low.
reset_limitedinputReset the CPU, peripherals, and data memory but preserves the instruction memory.
debugoutputTurned on for a clock cycle when the CPU executes a debug instruction.
debug_txoutputWhen debug_output is enabled, this line prints the content of the working register on debug instructions.
quitoutputIs turned on from the moment the CPU executes a quit instruction and stops itself.
gpi16-bit inputThe input of the GPIO.
gpo16-bit outputThe output of the GPIO.
rxinputThe rx line of the UART.
txoutputThe tx line of the UART.
pwmoutputOutput of the PWM.
segments7-bit outputSeven-segment control, an output value of 0 means that the segment is on.
seg_select4-bit outputSeven segments digit selection, an output value of 1 means that the digit is selected.
seg_colonoutputControl of the colon indicator of the seven-segment display, a value of 0 means that the colon is turned on.
seg_dotoutputControl of the decimal dot indicator of the seven-segment display, a value of 0 means that the dot is turned on.
synth_outoutputOutput of the frequency synthesizer.
ext_io_inselectable size inputInput of the extended IO module.
ext_io_outselectable size outputOutput of the extended IO module.

Using the bootloader

The bootloader is very easy to use. After the processor started, transmit the program through the UART connection and wait 4 seconds for the program to start. If 4 seconds is too long, you can use the parameter swift_bootloader to lower it to 50 ms.

About

A micro-controller based on a Reflet CPU

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Latest commit

History

195 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Reflet microcontroller

A micro-controller based on a Reflet CPU.

Part of the system are included as submodules, so you should run git submodule update --init --recursive after cloning this repository.

The CPU

The CPU is a Reflet CPU. More information and the toolchain can be found here: https://github.com/Arkaeriit/reflet.

Peripherals

All the Verilog files describing the peripherals and their submodules are in the peripheral folder.

All the peripherals are controlled and monitored with 8-bits registers to make them compatible with any Reflet CPU. Each register is only accessible with its exact address (even in 16-bit mode, editing the register at address 0xFF00 will not impact the register at address 0xFF01).

The peripherals are identified with a base address and are controlled by editing the register from the base address and a few bytes forwards. For example, with the 16-bit controller, the GPIO got 0xFF07 as its base address and is configured with the register at address 0xFF07 to 0xFF11.

To minimize the synthesis time and size of a reflet microcontroller, peripherals can be enabled or disabled with Verilog parameters.

Hardware info

This peripheral is always active. It is used to read the frequency of the system clock and which peripherals are enabled or not.

Offset with base addressTypeRegister nameEffect
0roclk_lsbContain the 8 LSB of the frequency of the main clock in MHz.
1roclk_msbContain the 8 MSB of the frequency of the main clock in MHz.
2roperiph_1Bits 0 to 2 contain info about the wordsize of the processor. 1 means that it is an 8-bit processor, 2 means a 16 bit, 3 32 bits, 4 64 bits, 5 128 bits, and 0 means any other wordsize. Bit 3 tells if the interrupt multiplexer is enabled. Bit 4 tells if the GPIO is enabled. Bit 5 tells if the timer is enabled. Bit 6 tells if the second timer is enabled. Finally, bit 7 tells if the UART is enabled.
3roperiph_2Bit 0 tells if the PWM is enabled. Bit 1 tells if the seven-segment controller is enabled. Bit 2 tells if the power manager is enabled. Bit 3 tells if the synthesizer is enabled. Bit 4 tells if the extended io is enabled. Bits 5 to 7 are left to 0.

Interrupt multiplexer

The CPU got only 4 interrupt lines, but more than 4 peripherals can raise interrupts. This module lets the user control which peripherals can use interrupts and the priority of each interrupt.

Offset with base addressTypeRegister nameEffect
0r/wint_enBit 0 control if the interrupt from the GPIO is enabled. Bit 1 control if the interrupt from the UART is enabled. Bit 2 control if the interrupt from the timer is enabled. Bit 3 control if the interrupt from timer 2 is enabled.
1r/wint_levelBits 0 and 1 control the priority of the GPIO interrupt. Bits 2 and 3 control the priority of the UART interrupt. Bits 4 and 5 control the priority of the timer interrupt. Bits 6 and 7 control the priority of the timer 2 interrupt.
2roreservedReserved for future used. Locked to 0 for now.
3r/wstatusThis register tells which interrupts are currently raised. Whenever a new interrupt appends, the related bit is raised to 1. To acknowledge the interrupt, its bit must be switched back to 0. Bit 0 tell the state of the GPIO interrupt. Bit 1 tells the state of the UART interrupt. Bit 2 tells the state of the timer interrupt. Bit 3 tells the state of the timer 2 interrupt.

GPIO

The most basic way to interact with the external world. It is made of a 16 bits parallel output and a 16 bits parallel input. The input can trigger an interrupt on the rising or falling edges of each input pin.

Offset with base addressTypeRegister nameEffect
0r/wgpo_lsbControl the 8 first pins of the parallel output.
1r/wgpo_msbControl the 8 last pins of the parallel output.
2rogpi_lsbContain the state of the 8 first pins of the parallel input.
3rogpi_msbContain the state of the 8 last pins of the parallel input.
4r/wrise_int_lsbControl which of the 8 first pins of the parallel input should raise an interrupt on a rising edge.
5r/wrise_int_msbControl which of the 8 last pins of the parallel input should raise an interrupt on a rising edge.
6r/wfall_int_lsbControl which of the 8 first pins of the parallel input should raise an interrupt on a falling edge.
7r/wfall_int_msbControl which of the 8 last pins of the parallel input should raise an interrupt on a falling edge.

Timer

A 24 bits timer. This timer contains two prescalers (pre1 and pre2) and the main counter (mcnt). Each of these 3 values is on 8 bits. The timer raise an interrupt each (pre1 + 1) * (pre2 + 1) * (mcnt) cycles of the system clock.

Offset with base addressTypeRegister nameEffect
0r/wpre1Control the value of pre1.
1r/wpre2Control the value of pre2.
2r/wmcntControl the value of mcnt.

Timer 2

A 23 bits timer. This timer behaves in a similar way to the main timer except that pre1 is on 7 bits instead of 8 and that we can select to use either the system clock or the output of the main timer as the input source. This makes it possible to chain timer and timer2 to have a resulting 47 bits timer.

Offset with base addressTypeRegister nameEffect
0r/wpre1Bit 0 should be set to 0 to use the system clock as an input source and set to 1 to use timer 1 as the input source. Bits 1 to 7 control the value of pre1.
1r/wpre2Control the value of pre2.
2r/wmcntControl the value of mcnt.

UART

A UART module with a baud rate locked at 9600. Its behavior is very similar to the IO functions of the Reflet simulator. To send a message, write its value in the tx_data register and put a 0 in tx_cmd. To receive a message, either enable the interrupt in the interrupt multiplexer or wait for the value in the rx_cmd register to be set to 0. The data will then be readable in the rx_data register.

Offset with base addressTypeRegister nameEffect
0r/wtx_cmdSet to 0 to send a message.
1r/wtx_dataWrite here the message to send.
2r/wrx_cmdThis register is automatically set to 0 when a byte is received.
3r/wrx_dataThe byte received is readable here.

PWM

A PWM module with up to 8 bits of resolution. Its frequency is configurable but the higher the frequency, the smaller the resolution. Its period is controllable with the freq register and its duty cycle with the duty register. The resulting duty cycle will be duty/freq.

Offset with base addressTypeRegister nameEffect
0r/wfreqSet the period of the PWM.
1r/wdutySet the duty-cycle.

Seven segments display controller

Even if this could be done with GPIO and a timer, a controller for seven segments display could be useful. This module is made to control 4 digits displays with colons and dots. In the selection bits, a 1 indicates that the digit is active. In the segments bits, 0 indicates that the segments must be lit.

Offset with base addressTypeRegister nameEffect
0r/wctrlBit 0 is used to enable or disable the display. Bit 1 is used to enable the colon. Bits 4 to 7 are used to select which dots must be turned on. Bits 2 and 3 are unused.
1r/wnum01Bits 0 to 3 are used to set the value of the first number. Bits 4 to 7 are used to set the value of the second number.
2r/wnum23Bits 0 to 3 are used to set the value of the third number. Bits 4 to 7 are used to set the value of the fourth number.

Power manager

This module is meant to either reduce the speed of the processor or disable it until an interrupt happens. To reduce the speed, a PWM signal is sent to the enable pin of the CPU.

Offset with base addressTypeRegister nameEffect
0r/wsleepWhen bit 0 is set to 1, the processor is disabled until a detected interrupt is raised. When bit 1 is set to 1, the processor is slowed down by a factor controlled in the power register. Bits 2 and 3 are unused. Bit 4 to 7 are used to tell if interrupts 0 to 3 are watched. If bit 4 is set to 1, the module will watch for interrupt 0 and unlock the processor if interrupt 0 is raised. Bit 5 will enable interrupt 1 and so on.
1r/wpowerThis register will let you choose the duty cycle to send to the enable pin of the CPU. The duty cycle is (the content of this register + 1)/256.

Frequency synthesizer

The documentation will come when the module will be done

Extended IO

If you need more than the 16 inputs and 16 outputs of the GPIO module, you can use this one to have up to 256 additional inputs and 256 output. The IOs can be selected with an address on a register and controlled with the other one. The inputs can not raise interrupt. The actual number of IO is chosen with a parameter of the controller module.

Offset with base addressTypeRegister nameEffect
0r/waddressSelect which IO is selected.
1r/wcontrolBit 0 contains the value in the selected input. Bit 1 contains the actual value of the selected output. To set the output, write the value you want in bit 2 and set bit 3 to 1. Bits 4 to 7 are unused.

Debug Helper

This module helps in debugging by printing over an UART line the content of the working register whenever a debug instruction is encountered. The data is sent at 9600 bauds in a little-endian fashion. When sending those data, the CPU is disabled to ensure that no debug instructions will be missed.

Controllers

The folder controller contains files used to make 8 bits or a 16 bits microcontroller with a Reflet CPU. As of now, for the 8-bit controller, you must copy the reflet_?bits_controller.v file and replace the data memory with a ROM with a valid Reflet program. For the 16-bit one, you can do so or choose to use the included bootloader instead.

8 bits controller

The 8 bits controller is very limited by its addressable space and thus, is only equipped with a limited amount of peripherals.

The memory map is the following:

StartEndContent
0x000x7FInstructions
0x800xECData
0xED0xFFPeripherals
----------------
0xED0xF0Interrupt multiplexer
0xF10xF8GPIO
0xF90xFBTimer
0xFC0xFFUART

Top-level module

The top-level module is in the controller folder and is named reflet_8bit_controller. It can not be used as-is because there is no way to fill its instruction memory. To use it, you must copy the top-level module and replace the mem_inst module with a ROM.

The parameters for this module are the following:

NameDescriptionDefault value
clk_freqThe frequency of the main clock in Hertz.1 000 000
debug_outputWhen set to 1, enable the debug helper module.0
enable_interrupt_muxIf equal to 0, the interrupt multiplexer is disabled.1
enable_gpioIf equal to 0, the GPIOs are disabled.1
enable_timerIf equal to 0, the timer is disabled.1
enable_uartIf equal to 0, the UART is disabled.1
mem_resetableIf not set to 0, the memories are reset to 0 when the reset signal is pulled down. This can be incompatible with some FPGA's memory blocks.0

The ports of this module are the following:

NameTypeDescription
clkinputThe main clock.
resetinputReset the controller when flipped to low.
debugoutputTurned on for a clock cycle when the CPU executes a debug instruction.
debug_txoutputWhen debug_output is enabled, this line prints the content of the working register on debug instructions.
quitoutputIs turned on from the moment the CPU executes a quit instruction and stops itself.
gpi16-bit inputThe input of the GPIO.
gpo16-bit outputThe output of the GPIO.
rxinputThe rx line of the UART.
txoutputThe tx line of the UART.

16 bits controller

The 16 bits controller is equipped with all the peripherals and its bigger addressable space makes it way easier to program for.

The memory map is the following:

StartEndContent
0x00000x7CFFInstructions
0x7D000x7FFFBootloader
0x80000xFEFFData
0xFF000xFFFFPeripherals
-------------------
0xFF000xFF03Hardware info
0xFF040xFF07Interrupt multiplexer
0xFF080xFF0FGPIO
0xFF100xFF12Timer
0xFF130xFF15Timer 2
0xFF160xFF19UART
0xFF1A0xFF1BPWM
0xFF1C0xFF1ESeven segments controller
0xFF1F0xFF20Power manager
0xFF210xFF21Frequency synthesizer
0xFF220xFF23Extended IO

Top-level module

The top-level module is in the controller folder and is named reflet_16bit_controller. Unlike its 8-bit counterpart, it can be used on its own as it is equipped with a bootloader that can be used to load a program in the data memory. Of course, if it is needed to only use a single program with an implementation, the mem_inst module can be replaced with a ROM.

The parameters for this module are the following:

NameDescriptionDefault value
clk_freqThe frequency of the main clock in Hertz.1 000 000
debug_outputWhen set to 1, enable the debug helper module.0
enable_interrupt_muxIf equal to 0, the interrupt multiplexer is disabled.1
enable_gpioIf equal to 0, the GPIOs are disabled.1
enable_timerIf equal to 0, the timer is disabled.1
enable_timer2If equal to 0, the timer2 is disabled.1
enable_uartIf equal to 0, the UART is disabled.1
enable_pwmIf equal to 0, the PWM is disabled.1
enable_segmentsIf equal to 0, the seven segments display controller is disabled.1
enable_power_managerIf equal to 0, the power manager is disabled.1
enable_synthIf equal to 0, the frequency synthesizer is disabled.1
enable_ext_ioIf equal to 0, the extended IO is disabled.1
data_sizeSize in bytes of the data memory.100
inst_sizeSize in bytes of the instruction memory.128
mem_resetableIf not set to 0, the memories are reset to 0 when the reset signal is pulled down. This can be incompatible with some FPGA's memory blocks.0
ext_io_sizeThe size of the extended io ports.128
swift_bootloaderUse a 50 ms bootloader timeout instead of 4 s.0

The ports of this module are the following:

NameTypeDescription
clkinputThe main clock.
resetinputReset the controller when flipped to low.
reset_limitedinputReset the CPU, peripherals, and data memory but preserves the instruction memory.
debugoutputTurned on for a clock cycle when the CPU executes a debug instruction.
debug_txoutputWhen debug_output is enabled, this line prints the content of the working register on debug instructions.
quitoutputIs turned on from the moment the CPU executes a quit instruction and stops itself.
gpi16-bit inputThe input of the GPIO.
gpo16-bit outputThe output of the GPIO.
rxinputThe rx line of the UART.
txoutputThe tx line of the UART.
pwmoutputOutput of the PWM.
segments7-bit outputSeven-segment control, an output value of 0 means that the segment is on.
seg_select4-bit outputSeven segments digit selection, an output value of 1 means that the digit is selected.
seg_colonoutputControl of the colon indicator of the seven-segment display, a value of 0 means that the colon is turned on.
seg_dotoutputControl of the decimal dot indicator of the seven-segment display, a value of 0 means that the dot is turned on.
synth_outoutputOutput of the frequency synthesizer.
ext_io_inselectable size inputInput of the extended IO module.
ext_io_outselectable size outputOutput of the extended IO module.

Using the bootloader

The bootloader is very easy to use. After the processor started, transmit the program through the UART connection and wait 4 seconds for the program to start. If 4 seconds is too long, you can use the parameter swift_bootloader to lower it to 50 ms.

About

A micro-controller based on a Reflet CPU

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

195 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Reflet microcontroller

A micro-controller based on a Reflet CPU.

Part of the system are included as submodules, so you should run git submodule update --init --recursive after cloning this repository.

The CPU

The CPU is a Reflet CPU. More information and the toolchain can be found here: https://github.com/Arkaeriit/reflet.

Peripherals

All the Verilog files describing the peripherals and their submodules are in the peripheral folder.

All the peripherals are controlled and monitored with 8-bits registers to make them compatible with any Reflet CPU. Each register is only accessible with its exact address (even in 16-bit mode, editing the register at address 0xFF00 will not impact the register at address 0xFF01).

The peripherals are identified with a base address and are controlled by editing the register from the base address and a few bytes forwards. For example, with the 16-bit controller, the GPIO got 0xFF07 as its base address and is configured with the register at address 0xFF07 to 0xFF11.

To minimize the synthesis time and size of a reflet microcontroller, peripherals can be enabled or disabled with Verilog parameters.

Hardware info

This peripheral is always active. It is used to read the frequency of the system clock and which peripherals are enabled or not.

Offset with base addressTypeRegister nameEffect
0roclk_lsbContain the 8 LSB of the frequency of the main clock in MHz.
1roclk_msbContain the 8 MSB of the frequency of the main clock in MHz.
2roperiph_1Bits 0 to 2 contain info about the wordsize of the processor. 1 means that it is an 8-bit processor, 2 means a 16 bit, 3 32 bits, 4 64 bits, 5 128 bits, and 0 means any other wordsize. Bit 3 tells if the interrupt multiplexer is enabled. Bit 4 tells if the GPIO is enabled. Bit 5 tells if the timer is enabled. Bit 6 tells if the second timer is enabled. Finally, bit 7 tells if the UART is enabled.
3roperiph_2Bit 0 tells if the PWM is enabled. Bit 1 tells if the seven-segment controller is enabled. Bit 2 tells if the power manager is enabled. Bit 3 tells if the synthesizer is enabled. Bit 4 tells if the extended io is enabled. Bits 5 to 7 are left to 0.

Interrupt multiplexer

The CPU got only 4 interrupt lines, but more than 4 peripherals can raise interrupts. This module lets the user control which peripherals can use interrupts and the priority of each interrupt.

Offset with base addressTypeRegister nameEffect
0r/wint_enBit 0 control if the interrupt from the GPIO is enabled. Bit 1 control if the interrupt from the UART is enabled. Bit 2 control if the interrupt from the timer is enabled. Bit 3 control if the interrupt from timer 2 is enabled.
1r/wint_levelBits 0 and 1 control the priority of the GPIO interrupt. Bits 2 and 3 control the priority of the UART interrupt. Bits 4 and 5 control the priority of the timer interrupt. Bits 6 and 7 control the priority of the timer 2 interrupt.
2roreservedReserved for future used. Locked to 0 for now.
3r/wstatusThis register tells which interrupts are currently raised. Whenever a new interrupt appends, the related bit is raised to 1. To acknowledge the interrupt, its bit must be switched back to 0. Bit 0 tell the state of the GPIO interrupt. Bit 1 tells the state of the UART interrupt. Bit 2 tells the state of the timer interrupt. Bit 3 tells the state of the timer 2 interrupt.

GPIO

The most basic way to interact with the external world. It is made of a 16 bits parallel output and a 16 bits parallel input. The input can trigger an interrupt on the rising or falling edges of each input pin.

Offset with base addressTypeRegister nameEffect
0r/wgpo_lsbControl the 8 first pins of the parallel output.
1r/wgpo_msbControl the 8 last pins of the parallel output.
2rogpi_lsbContain the state of the 8 first pins of the parallel input.
3rogpi_msbContain the state of the 8 last pins of the parallel input.
4r/wrise_int_lsbControl which of the 8 first pins of the parallel input should raise an interrupt on a rising edge.
5r/wrise_int_msbControl which of the 8 last pins of the parallel input should raise an interrupt on a rising edge.
6r/wfall_int_lsbControl which of the 8 first pins of the parallel input should raise an interrupt on a falling edge.
7r/wfall_int_msbControl which of the 8 last pins of the parallel input should raise an interrupt on a falling edge.

Timer

A 24 bits timer. This timer contains two prescalers (pre1 and pre2) and the main counter (mcnt). Each of these 3 values is on 8 bits. The timer raise an interrupt each (pre1 + 1) * (pre2 + 1) * (mcnt) cycles of the system clock.

Offset with base addressTypeRegister nameEffect
0r/wpre1Control the value of pre1.
1r/wpre2Control the value of pre2.
2r/wmcntControl the value of mcnt.

Timer 2

A 23 bits timer. This timer behaves in a similar way to the main timer except that pre1 is on 7 bits instead of 8 and that we can select to use either the system clock or the output of the main timer as the input source. This makes it possible to chain timer and timer2 to have a resulting 47 bits timer.

Offset with base addressTypeRegister nameEffect
0r/wpre1Bit 0 should be set to 0 to use the system clock as an input source and set to 1 to use timer 1 as the input source. Bits 1 to 7 control the value of pre1.
1r/wpre2Control the value of pre2.
2r/wmcntControl the value of mcnt.

UART

A UART module with a baud rate locked at 9600. Its behavior is very similar to the IO functions of the Reflet simulator. To send a message, write its value in the tx_data register and put a 0 in tx_cmd. To receive a message, either enable the interrupt in the interrupt multiplexer or wait for the value in the rx_cmd register to be set to 0. The data will then be readable in the rx_data register.

Offset with base addressTypeRegister nameEffect
0r/wtx_cmdSet to 0 to send a message.
1r/wtx_dataWrite here the message to send.
2r/wrx_cmdThis register is automatically set to 0 when a byte is received.
3r/wrx_dataThe byte received is readable here.

PWM

A PWM module with up to 8 bits of resolution. Its frequency is configurable but the higher the frequency, the smaller the resolution. Its period is controllable with the freq register and its duty cycle with the duty register. The resulting duty cycle will be duty/freq.

Offset with base addressTypeRegister nameEffect
0r/wfreqSet the period of the PWM.
1r/wdutySet the duty-cycle.

Seven segments display controller

Even if this could be done with GPIO and a timer, a controller for seven segments display could be useful. This module is made to control 4 digits displays with colons and dots. In the selection bits, a 1 indicates that the digit is active. In the segments bits, 0 indicates that the segments must be lit.

Offset with base addressTypeRegister nameEffect
0r/wctrlBit 0 is used to enable or disable the display. Bit 1 is used to enable the colon. Bits 4 to 7 are used to select which dots must be turned on. Bits 2 and 3 are unused.
1r/wnum01Bits 0 to 3 are used to set the value of the first number. Bits 4 to 7 are used to set the value of the second number.
2r/wnum23Bits 0 to 3 are used to set the value of the third number. Bits 4 to 7 are used to set the value of the fourth number.

Power manager

This module is meant to either reduce the speed of the processor or disable it until an interrupt happens. To reduce the speed, a PWM signal is sent to the enable pin of the CPU.

Offset with base addressTypeRegister nameEffect
0r/wsleepWhen bit 0 is set to 1, the processor is disabled until a detected interrupt is raised. When bit 1 is set to 1, the processor is slowed down by a factor controlled in the power register. Bits 2 and 3 are unused. Bit 4 to 7 are used to tell if interrupts 0 to 3 are watched. If bit 4 is set to 1, the module will watch for interrupt 0 and unlock the processor if interrupt 0 is raised. Bit 5 will enable interrupt 1 and so on.
1r/wpowerThis register will let you choose the duty cycle to send to the enable pin of the CPU. The duty cycle is (the content of this register + 1)/256.

Frequency synthesizer

The documentation will come when the module will be done

Extended IO

If you need more than the 16 inputs and 16 outputs of the GPIO module, you can use this one to have up to 256 additional inputs and 256 output. The IOs can be selected with an address on a register and controlled with the other one. The inputs can not raise interrupt. The actual number of IO is chosen with a parameter of the controller module.

Offset with base addressTypeRegister nameEffect
0r/waddressSelect which IO is selected.
1r/wcontrolBit 0 contains the value in the selected input. Bit 1 contains the actual value of the selected output. To set the output, write the value you want in bit 2 and set bit 3 to 1. Bits 4 to 7 are unused.

Debug Helper

This module helps in debugging by printing over an UART line the content of the working register whenever a debug instruction is encountered. The data is sent at 9600 bauds in a little-endian fashion. When sending those data, the CPU is disabled to ensure that no debug instructions will be missed.

Controllers

The folder controller contains files used to make 8 bits or a 16 bits microcontroller with a Reflet CPU. As of now, for the 8-bit controller, you must copy the reflet_?bits_controller.v file and replace the data memory with a ROM with a valid Reflet program. For the 16-bit one, you can do so or choose to use the included bootloader instead.

8 bits controller

The 8 bits controller is very limited by its addressable space and thus, is only equipped with a limited amount of peripherals.

The memory map is the following:

StartEndContent
0x000x7FInstructions
0x800xECData
0xED0xFFPeripherals
----------------
0xED0xF0Interrupt multiplexer
0xF10xF8GPIO
0xF90xFBTimer
0xFC0xFFUART

Top-level module

The top-level module is in the controller folder and is named reflet_8bit_controller. It can not be used as-is because there is no way to fill its instruction memory. To use it, you must copy the top-level module and replace the mem_inst module with a ROM.

The parameters for this module are the following:

NameDescriptionDefault value
clk_freqThe frequency of the main clock in Hertz.1 000 000
debug_outputWhen set to 1, enable the debug helper module.0
enable_interrupt_muxIf equal to 0, the interrupt multiplexer is disabled.1
enable_gpioIf equal to 0, the GPIOs are disabled.1
enable_timerIf equal to 0, the timer is disabled.1
enable_uartIf equal to 0, the UART is disabled.1
mem_resetableIf not set to 0, the memories are reset to 0 when the reset signal is pulled down. This can be incompatible with some FPGA's memory blocks.0

The ports of this module are the following:

NameTypeDescription
clkinputThe main clock.
resetinputReset the controller when flipped to low.
debugoutputTurned on for a clock cycle when the CPU executes a debug instruction.
debug_txoutputWhen debug_output is enabled, this line prints the content of the working register on debug instructions.
quitoutputIs turned on from the moment the CPU executes a quit instruction and stops itself.
gpi16-bit inputThe input of the GPIO.
gpo16-bit outputThe output of the GPIO.
rxinputThe rx line of the UART.
txoutputThe tx line of the UART.

16 bits controller

The 16 bits controller is equipped with all the peripherals and its bigger addressable space makes it way easier to program for.

The memory map is the following:

StartEndContent
0x00000x7CFFInstructions
0x7D000x7FFFBootloader
0x80000xFEFFData
0xFF000xFFFFPeripherals
-------------------
0xFF000xFF03Hardware info
0xFF040xFF07Interrupt multiplexer
0xFF080xFF0FGPIO
0xFF100xFF12Timer
0xFF130xFF15Timer 2
0xFF160xFF19UART
0xFF1A0xFF1BPWM
0xFF1C0xFF1ESeven segments controller
0xFF1F0xFF20Power manager
0xFF210xFF21Frequency synthesizer
0xFF220xFF23Extended IO

Top-level module

The top-level module is in the controller folder and is named reflet_16bit_controller. Unlike its 8-bit counterpart, it can be used on its own as it is equipped with a bootloader that can be used to load a program in the data memory. Of course, if it is needed to only use a single program with an implementation, the mem_inst module can be replaced with a ROM.

The parameters for this module are the following:

NameDescriptionDefault value
clk_freqThe frequency of the main clock in Hertz.1 000 000
debug_outputWhen set to 1, enable the debug helper module.0
enable_interrupt_muxIf equal to 0, the interrupt multiplexer is disabled.1
enable_gpioIf equal to 0, the GPIOs are disabled.1
enable_timerIf equal to 0, the timer is disabled.1
enable_timer2If equal to 0, the timer2 is disabled.1
enable_uartIf equal to 0, the UART is disabled.1
enable_pwmIf equal to 0, the PWM is disabled.1
enable_segmentsIf equal to 0, the seven segments display controller is disabled.1
enable_power_managerIf equal to 0, the power manager is disabled.1
enable_synthIf equal to 0, the frequency synthesizer is disabled.1
enable_ext_ioIf equal to 0, the extended IO is disabled.1
data_sizeSize in bytes of the data memory.100
inst_sizeSize in bytes of the instruction memory.128
mem_resetableIf not set to 0, the memories are reset to 0 when the reset signal is pulled down. This can be incompatible with some FPGA's memory blocks.0
ext_io_sizeThe size of the extended io ports.128
swift_bootloaderUse a 50 ms bootloader timeout instead of 4 s.0

The ports of this module are the following:

NameTypeDescription
clkinputThe main clock.
resetinputReset the controller when flipped to low.
reset_limitedinputReset the CPU, peripherals, and data memory but preserves the instruction memory.
debugoutputTurned on for a clock cycle when the CPU executes a debug instruction.
debug_txoutputWhen debug_output is enabled, this line prints the content of the working register on debug instructions.
quitoutputIs turned on from the moment the CPU executes a quit instruction and stops itself.
gpi16-bit inputThe input of the GPIO.
gpo16-bit outputThe output of the GPIO.
rxinputThe rx line of the UART.
txoutputThe tx line of the UART.
pwmoutputOutput of the PWM.
segments7-bit outputSeven-segment control, an output value of 0 means that the segment is on.
seg_select4-bit outputSeven segments digit selection, an output value of 1 means that the digit is selected.
seg_colonoutputControl of the colon indicator of the seven-segment display, a value of 0 means that the colon is turned on.
seg_dotoutputControl of the decimal dot indicator of the seven-segment display, a value of 0 means that the dot is turned on.
synth_outoutputOutput of the frequency synthesizer.
ext_io_inselectable size inputInput of the extended IO module.
ext_io_outselectable size outputOutput of the extended IO module.

Using the bootloader

The bootloader is very easy to use. After the processor started, transmit the program through the UART connection and wait 4 seconds for the program to start. If 4 seconds is too long, you can use the parameter swift_bootloader to lower it to 50 ms.

About

A micro-controller based on a Reflet CPU

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

195 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Reflet microcontroller

A micro-controller based on a Reflet CPU.

Part of the system are included as submodules, so you should run git submodule update --init --recursive after cloning this repository.

The CPU

The CPU is a Reflet CPU. More information and the toolchain can be found here: https://github.com/Arkaeriit/reflet.

Peripherals

All the Verilog files describing the peripherals and their submodules are in the peripheral folder.

All the peripherals are controlled and monitored with 8-bits registers to make them compatible with any Reflet CPU. Each register is only accessible with its exact address (even in 16-bit mode, editing the register at address 0xFF00 will not impact the register at address 0xFF01).

The peripherals are identified with a base address and are controlled by editing the register from the base address and a few bytes forwards. For example, with the 16-bit controller, the GPIO got 0xFF07 as its base address and is configured with the register at address 0xFF07 to 0xFF11.

To minimize the synthesis time and size of a reflet microcontroller, peripherals can be enabled or disabled with Verilog parameters.

Hardware info

This peripheral is always active. It is used to read the frequency of the system clock and which peripherals are enabled or not.

Offset with base addressTypeRegister nameEffect
0roclk_lsbContain the 8 LSB of the frequency of the main clock in MHz.
1roclk_msbContain the 8 MSB of the frequency of the main clock in MHz.
2roperiph_1Bits 0 to 2 contain info about the wordsize of the processor. 1 means that it is an 8-bit processor, 2 means a 16 bit, 3 32 bits, 4 64 bits, 5 128 bits, and 0 means any other wordsize. Bit 3 tells if the interrupt multiplexer is enabled. Bit 4 tells if the GPIO is enabled. Bit 5 tells if the timer is enabled. Bit 6 tells if the second timer is enabled. Finally, bit 7 tells if the UART is enabled.
3roperiph_2Bit 0 tells if the PWM is enabled. Bit 1 tells if the seven-segment controller is enabled. Bit 2 tells if the power manager is enabled. Bit 3 tells if the synthesizer is enabled. Bit 4 tells if the extended io is enabled. Bits 5 to 7 are left to 0.

Interrupt multiplexer

The CPU got only 4 interrupt lines, but more than 4 peripherals can raise interrupts. This module lets the user control which peripherals can use interrupts and the priority of each interrupt.

Offset with base addressTypeRegister nameEffect
0r/wint_enBit 0 control if the interrupt from the GPIO is enabled. Bit 1 control if the interrupt from the UART is enabled. Bit 2 control if the interrupt from the timer is enabled. Bit 3 control if the interrupt from timer 2 is enabled.
1r/wint_levelBits 0 and 1 control the priority of the GPIO interrupt. Bits 2 and 3 control the priority of the UART interrupt. Bits 4 and 5 control the priority of the timer interrupt. Bits 6 and 7 control the priority of the timer 2 interrupt.
2roreservedReserved for future used. Locked to 0 for now.
3r/wstatusThis register tells which interrupts are currently raised. Whenever a new interrupt appends, the related bit is raised to 1. To acknowledge the interrupt, its bit must be switched back to 0. Bit 0 tell the state of the GPIO interrupt. Bit 1 tells the state of the UART interrupt. Bit 2 tells the state of the timer interrupt. Bit 3 tells the state of the timer 2 interrupt.

GPIO

The most basic way to interact with the external world. It is made of a 16 bits parallel output and a 16 bits parallel input. The input can trigger an interrupt on the rising or falling edges of each input pin.

Offset with base addressTypeRegister nameEffect
0r/wgpo_lsbControl the 8 first pins of the parallel output.
1r/wgpo_msbControl the 8 last pins of the parallel output.
2rogpi_lsbContain the state of the 8 first pins of the parallel input.
3rogpi_msbContain the state of the 8 last pins of the parallel input.
4r/wrise_int_lsbControl which of the 8 first pins of the parallel input should raise an interrupt on a rising edge.
5r/wrise_int_msbControl which of the 8 last pins of the parallel input should raise an interrupt on a rising edge.
6r/wfall_int_lsbControl which of the 8 first pins of the parallel input should raise an interrupt on a falling edge.
7r/wfall_int_msbControl which of the 8 last pins of the parallel input should raise an interrupt on a falling edge.

Timer

A 24 bits timer. This timer contains two prescalers (pre1 and pre2) and the main counter (mcnt). Each of these 3 values is on 8 bits. The timer raise an interrupt each (pre1 + 1) * (pre2 + 1) * (mcnt) cycles of the system clock.

Offset with base addressTypeRegister nameEffect
0r/wpre1Control the value of pre1.
1r/wpre2Control the value of pre2.
2r/wmcntControl the value of mcnt.

Timer 2

A 23 bits timer. This timer behaves in a similar way to the main timer except that pre1 is on 7 bits instead of 8 and that we can select to use either the system clock or the output of the main timer as the input source. This makes it possible to chain timer and timer2 to have a resulting 47 bits timer.

Offset with base addressTypeRegister nameEffect
0r/wpre1Bit 0 should be set to 0 to use the system clock as an input source and set to 1 to use timer 1 as the input source. Bits 1 to 7 control the value of pre1.
1r/wpre2Control the value of pre2.
2r/wmcntControl the value of mcnt.

UART

A UART module with a baud rate locked at 9600. Its behavior is very similar to the IO functions of the Reflet simulator. To send a message, write its value in the tx_data register and put a 0 in tx_cmd. To receive a message, either enable the interrupt in the interrupt multiplexer or wait for the value in the rx_cmd register to be set to 0. The data will then be readable in the rx_data register.

Offset with base addressTypeRegister nameEffect
0r/wtx_cmdSet to 0 to send a message.
1r/wtx_dataWrite here the message to send.
2r/wrx_cmdThis register is automatically set to 0 when a byte is received.
3r/wrx_dataThe byte received is readable here.

PWM

A PWM module with up to 8 bits of resolution. Its frequency is configurable but the higher the frequency, the smaller the resolution. Its period is controllable with the freq register and its duty cycle with the duty register. The resulting duty cycle will be duty/freq.

Offset with base addressTypeRegister nameEffect
0r/wfreqSet the period of the PWM.
1r/wdutySet the duty-cycle.

Seven segments display controller

Even if this could be done with GPIO and a timer, a controller for seven segments display could be useful. This module is made to control 4 digits displays with colons and dots. In the selection bits, a 1 indicates that the digit is active. In the segments bits, 0 indicates that the segments must be lit.

Offset with base addressTypeRegister nameEffect
0r/wctrlBit 0 is used to enable or disable the display. Bit 1 is used to enable the colon. Bits 4 to 7 are used to select which dots must be turned on. Bits 2 and 3 are unused.
1r/wnum01Bits 0 to 3 are used to set the value of the first number. Bits 4 to 7 are used to set the value of the second number.
2r/wnum23Bits 0 to 3 are used to set the value of the third number. Bits 4 to 7 are used to set the value of the fourth number.

Power manager

This module is meant to either reduce the speed of the processor or disable it until an interrupt happens. To reduce the speed, a PWM signal is sent to the enable pin of the CPU.

Offset with base addressTypeRegister nameEffect
0r/wsleepWhen bit 0 is set to 1, the processor is disabled until a detected interrupt is raised. When bit 1 is set to 1, the processor is slowed down by a factor controlled in the power register. Bits 2 and 3 are unused. Bit 4 to 7 are used to tell if interrupts 0 to 3 are watched. If bit 4 is set to 1, the module will watch for interrupt 0 and unlock the processor if interrupt 0 is raised. Bit 5 will enable interrupt 1 and so on.
1r/wpowerThis register will let you choose the duty cycle to send to the enable pin of the CPU. The duty cycle is (the content of this register + 1)/256.

Frequency synthesizer

The documentation will come when the module will be done

Extended IO

If you need more than the 16 inputs and 16 outputs of the GPIO module, you can use this one to have up to 256 additional inputs and 256 output. The IOs can be selected with an address on a register and controlled with the other one. The inputs can not raise interrupt. The actual number of IO is chosen with a parameter of the controller module.

Offset with base addressTypeRegister nameEffect
0r/waddressSelect which IO is selected.
1r/wcontrolBit 0 contains the value in the selected input. Bit 1 contains the actual value of the selected output. To set the output, write the value you want in bit 2 and set bit 3 to 1. Bits 4 to 7 are unused.

Debug Helper

This module helps in debugging by printing over an UART line the content of the working register whenever a debug instruction is encountered. The data is sent at 9600 bauds in a little-endian fashion. When sending those data, the CPU is disabled to ensure that no debug instructions will be missed.

Controllers

The folder controller contains files used to make 8 bits or a 16 bits microcontroller with a Reflet CPU. As of now, for the 8-bit controller, you must copy the reflet_?bits_controller.v file and replace the data memory with a ROM with a valid Reflet program. For the 16-bit one, you can do so or choose to use the included bootloader instead.

8 bits controller

The 8 bits controller is very limited by its addressable space and thus, is only equipped with a limited amount of peripherals.

The memory map is the following:

StartEndContent
0x000x7FInstructions
0x800xECData
0xED0xFFPeripherals
----------------
0xED0xF0Interrupt multiplexer
0xF10xF8GPIO
0xF90xFBTimer
0xFC0xFFUART

Top-level module

The top-level module is in the controller folder and is named reflet_8bit_controller. It can not be used as-is because there is no way to fill its instruction memory. To use it, you must copy the top-level module and replace the mem_inst module with a ROM.

The parameters for this module are the following:

NameDescriptionDefault value
clk_freqThe frequency of the main clock in Hertz.1 000 000
debug_outputWhen set to 1, enable the debug helper module.0
enable_interrupt_muxIf equal to 0, the interrupt multiplexer is disabled.1
enable_gpioIf equal to 0, the GPIOs are disabled.1
enable_timerIf equal to 0, the timer is disabled.1
enable_uartIf equal to 0, the UART is disabled.1
mem_resetableIf not set to 0, the memories are reset to 0 when the reset signal is pulled down. This can be incompatible with some FPGA's memory blocks.0

The ports of this module are the following:

NameTypeDescription
clkinputThe main clock.
resetinputReset the controller when flipped to low.
debugoutputTurned on for a clock cycle when the CPU executes a debug instruction.
debug_txoutputWhen debug_output is enabled, this line prints the content of the working register on debug instructions.
quitoutputIs turned on from the moment the CPU executes a quit instruction and stops itself.
gpi16-bit inputThe input of the GPIO.
gpo16-bit outputThe output of the GPIO.
rxinputThe rx line of the UART.
txoutputThe tx line of the UART.

16 bits controller

The 16 bits controller is equipped with all the peripherals and its bigger addressable space makes it way easier to program for.

The memory map is the following:

StartEndContent
0x00000x7CFFInstructions
0x7D000x7FFFBootloader
0x80000xFEFFData
0xFF000xFFFFPeripherals
-------------------
0xFF000xFF03Hardware info
0xFF040xFF07Interrupt multiplexer
0xFF080xFF0FGPIO
0xFF100xFF12Timer
0xFF130xFF15Timer 2
0xFF160xFF19UART
0xFF1A0xFF1BPWM
0xFF1C0xFF1ESeven segments controller
0xFF1F0xFF20Power manager
0xFF210xFF21Frequency synthesizer
0xFF220xFF23Extended IO

Top-level module

The top-level module is in the controller folder and is named reflet_16bit_controller. Unlike its 8-bit counterpart, it can be used on its own as it is equipped with a bootloader that can be used to load a program in the data memory. Of course, if it is needed to only use a single program with an implementation, the mem_inst module can be replaced with a ROM.

The parameters for this module are the following:

NameDescriptionDefault value
clk_freqThe frequency of the main clock in Hertz.1 000 000
debug_outputWhen set to 1, enable the debug helper module.0
enable_interrupt_muxIf equal to 0, the interrupt multiplexer is disabled.1
enable_gpioIf equal to 0, the GPIOs are disabled.1
enable_timerIf equal to 0, the timer is disabled.1
enable_timer2If equal to 0, the timer2 is disabled.1
enable_uartIf equal to 0, the UART is disabled.1
enable_pwmIf equal to 0, the PWM is disabled.1
enable_segmentsIf equal to 0, the seven segments display controller is disabled.1
enable_power_managerIf equal to 0, the power manager is disabled.1
enable_synthIf equal to 0, the frequency synthesizer is disabled.1
enable_ext_ioIf equal to 0, the extended IO is disabled.1
data_sizeSize in bytes of the data memory.100
inst_sizeSize in bytes of the instruction memory.128
mem_resetableIf not set to 0, the memories are reset to 0 when the reset signal is pulled down. This can be incompatible with some FPGA's memory blocks.0
ext_io_sizeThe size of the extended io ports.128
swift_bootloaderUse a 50 ms bootloader timeout instead of 4 s.0

The ports of this module are the following:

NameTypeDescription
clkinputThe main clock.
resetinputReset the controller when flipped to low.
reset_limitedinputReset the CPU, peripherals, and data memory but preserves the instruction memory.
debugoutputTurned on for a clock cycle when the CPU executes a debug instruction.
debug_txoutputWhen debug_output is enabled, this line prints the content of the working register on debug instructions.
quitoutputIs turned on from the moment the CPU executes a quit instruction and stops itself.
gpi16-bit inputThe input of the GPIO.
gpo16-bit outputThe output of the GPIO.
rxinputThe rx line of the UART.
txoutputThe tx line of the UART.
pwmoutputOutput of the PWM.
segments7-bit outputSeven-segment control, an output value of 0 means that the segment is on.
seg_select4-bit outputSeven segments digit selection, an output value of 1 means that the digit is selected.
seg_colonoutputControl of the colon indicator of the seven-segment display, a value of 0 means that the colon is turned on.
seg_dotoutputControl of the decimal dot indicator of the seven-segment display, a value of 0 means that the dot is turned on.
synth_outoutputOutput of the frequency synthesizer.
ext_io_inselectable size inputInput of the extended IO module.
ext_io_outselectable size outputOutput of the extended IO module.

Using the bootloader

The bootloader is very easy to use. After the processor started, transmit the program through the UART connection and wait 4 seconds for the program to start. If 4 seconds is too long, you can use the parameter swift_bootloader to lower it to 50 ms.

About

A micro-controller based on a Reflet CPU

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Latest commit

History

195 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Reflet microcontroller

A micro-controller based on a Reflet CPU.

Part of the system are included as submodules, so you should run git submodule update --init --recursive after cloning this repository.

The CPU

The CPU is a Reflet CPU. More information and the toolchain can be found here: https://github.com/Arkaeriit/reflet.

Peripherals

All the Verilog files describing the peripherals and their submodules are in the peripheral folder.

All the peripherals are controlled and monitored with 8-bits registers to make them compatible with any Reflet CPU. Each register is only accessible with its exact address (even in 16-bit mode, editing the register at address 0xFF00 will not impact the register at address 0xFF01).

The peripherals are identified with a base address and are controlled by editing the register from the base address and a few bytes forwards. For example, with the 16-bit controller, the GPIO got 0xFF07 as its base address and is configured with the register at address 0xFF07 to 0xFF11.

To minimize the synthesis time and size of a reflet microcontroller, peripherals can be enabled or disabled with Verilog parameters.

Hardware info

This peripheral is always active. It is used to read the frequency of the system clock and which peripherals are enabled or not.

Offset with base addressTypeRegister nameEffect
0roclk_lsbContain the 8 LSB of the frequency of the main clock in MHz.
1roclk_msbContain the 8 MSB of the frequency of the main clock in MHz.
2roperiph_1Bits 0 to 2 contain info about the wordsize of the processor. 1 means that it is an 8-bit processor, 2 means a 16 bit, 3 32 bits, 4 64 bits, 5 128 bits, and 0 means any other wordsize. Bit 3 tells if the interrupt multiplexer is enabled. Bit 4 tells if the GPIO is enabled. Bit 5 tells if the timer is enabled. Bit 6 tells if the second timer is enabled. Finally, bit 7 tells if the UART is enabled.
3roperiph_2Bit 0 tells if the PWM is enabled. Bit 1 tells if the seven-segment controller is enabled. Bit 2 tells if the power manager is enabled. Bit 3 tells if the synthesizer is enabled. Bit 4 tells if the extended io is enabled. Bits 5 to 7 are left to 0.

Interrupt multiplexer

The CPU got only 4 interrupt lines, but more than 4 peripherals can raise interrupts. This module lets the user control which peripherals can use interrupts and the priority of each interrupt.

Offset with base addressTypeRegister nameEffect
0r/wint_enBit 0 control if the interrupt from the GPIO is enabled. Bit 1 control if the interrupt from the UART is enabled. Bit 2 control if the interrupt from the timer is enabled. Bit 3 control if the interrupt from timer 2 is enabled.
1r/wint_levelBits 0 and 1 control the priority of the GPIO interrupt. Bits 2 and 3 control the priority of the UART interrupt. Bits 4 and 5 control the priority of the timer interrupt. Bits 6 and 7 control the priority of the timer 2 interrupt.
2roreservedReserved for future used. Locked to 0 for now.
3r/wstatusThis register tells which interrupts are currently raised. Whenever a new interrupt appends, the related bit is raised to 1. To acknowledge the interrupt, its bit must be switched back to 0. Bit 0 tell the state of the GPIO interrupt. Bit 1 tells the state of the UART interrupt. Bit 2 tells the state of the timer interrupt. Bit 3 tells the state of the timer 2 interrupt.

GPIO

The most basic way to interact with the external world. It is made of a 16 bits parallel output and a 16 bits parallel input. The input can trigger an interrupt on the rising or falling edges of each input pin.

Offset with base addressTypeRegister nameEffect
0r/wgpo_lsbControl the 8 first pins of the parallel output.
1r/wgpo_msbControl the 8 last pins of the parallel output.
2rogpi_lsbContain the state of the 8 first pins of the parallel input.
3rogpi_msbContain the state of the 8 last pins of the parallel input.
4r/wrise_int_lsbControl which of the 8 first pins of the parallel input should raise an interrupt on a rising edge.
5r/wrise_int_msbControl which of the 8 last pins of the parallel input should raise an interrupt on a rising edge.
6r/wfall_int_lsbControl which of the 8 first pins of the parallel input should raise an interrupt on a falling edge.
7r/wfall_int_msbControl which of the 8 last pins of the parallel input should raise an interrupt on a falling edge.

Timer

A 24 bits timer. This timer contains two prescalers (pre1 and pre2) and the main counter (mcnt). Each of these 3 values is on 8 bits. The timer raise an interrupt each (pre1 + 1) * (pre2 + 1) * (mcnt) cycles of the system clock.

Offset with base addressTypeRegister nameEffect
0r/wpre1Control the value of pre1.
1r/wpre2Control the value of pre2.
2r/wmcntControl the value of mcnt.

Timer 2

A 23 bits timer. This timer behaves in a similar way to the main timer except that pre1 is on 7 bits instead of 8 and that we can select to use either the system clock or the output of the main timer as the input source. This makes it possible to chain timer and timer2 to have a resulting 47 bits timer.

Offset with base addressTypeRegister nameEffect
0r/wpre1Bit 0 should be set to 0 to use the system clock as an input source and set to 1 to use timer 1 as the input source. Bits 1 to 7 control the value of pre1.
1r/wpre2Control the value of pre2.
2r/wmcntControl the value of mcnt.

UART

A UART module with a baud rate locked at 9600. Its behavior is very similar to the IO functions of the Reflet simulator. To send a message, write its value in the tx_data register and put a 0 in tx_cmd. To receive a message, either enable the interrupt in the interrupt multiplexer or wait for the value in the rx_cmd register to be set to 0. The data will then be readable in the rx_data register.

Offset with base addressTypeRegister nameEffect
0r/wtx_cmdSet to 0 to send a message.
1r/wtx_dataWrite here the message to send.
2r/wrx_cmdThis register is automatically set to 0 when a byte is received.
3r/wrx_dataThe byte received is readable here.

PWM

A PWM module with up to 8 bits of resolution. Its frequency is configurable but the higher the frequency, the smaller the resolution. Its period is controllable with the freq register and its duty cycle with the duty register. The resulting duty cycle will be duty/freq.

Offset with base addressTypeRegister nameEffect
0r/wfreqSet the period of the PWM.
1r/wdutySet the duty-cycle.

Seven segments display controller

Even if this could be done with GPIO and a timer, a controller for seven segments display could be useful. This module is made to control 4 digits displays with colons and dots. In the selection bits, a 1 indicates that the digit is active. In the segments bits, 0 indicates that the segments must be lit.

Offset with base addressTypeRegister nameEffect
0r/wctrlBit 0 is used to enable or disable the display. Bit 1 is used to enable the colon. Bits 4 to 7 are used to select which dots must be turned on. Bits 2 and 3 are unused.
1r/wnum01Bits 0 to 3 are used to set the value of the first number. Bits 4 to 7 are used to set the value of the second number.
2r/wnum23Bits 0 to 3 are used to set the value of the third number. Bits 4 to 7 are used to set the value of the fourth number.

Power manager

This module is meant to either reduce the speed of the processor or disable it until an interrupt happens. To reduce the speed, a PWM signal is sent to the enable pin of the CPU.

Offset with base addressTypeRegister nameEffect
0r/wsleepWhen bit 0 is set to 1, the processor is disabled until a detected interrupt is raised. When bit 1 is set to 1, the processor is slowed down by a factor controlled in the power register. Bits 2 and 3 are unused. Bit 4 to 7 are used to tell if interrupts 0 to 3 are watched. If bit 4 is set to 1, the module will watch for interrupt 0 and unlock the processor if interrupt 0 is raised. Bit 5 will enable interrupt 1 and so on.
1r/wpowerThis register will let you choose the duty cycle to send to the enable pin of the CPU. The duty cycle is (the content of this register + 1)/256.

Frequency synthesizer

The documentation will come when the module will be done

Extended IO

If you need more than the 16 inputs and 16 outputs of the GPIO module, you can use this one to have up to 256 additional inputs and 256 output. The IOs can be selected with an address on a register and controlled with the other one. The inputs can not raise interrupt. The actual number of IO is chosen with a parameter of the controller module.

Offset with base addressTypeRegister nameEffect
0r/waddressSelect which IO is selected.
1r/wcontrolBit 0 contains the value in the selected input. Bit 1 contains the actual value of the selected output. To set the output, write the value you want in bit 2 and set bit 3 to 1. Bits 4 to 7 are unused.

Debug Helper

This module helps in debugging by printing over an UART line the content of the working register whenever a debug instruction is encountered. The data is sent at 9600 bauds in a little-endian fashion. When sending those data, the CPU is disabled to ensure that no debug instructions will be missed.

Controllers

The folder controller contains files used to make 8 bits or a 16 bits microcontroller with a Reflet CPU. As of now, for the 8-bit controller, you must copy the reflet_?bits_controller.v file and replace the data memory with a ROM with a valid Reflet program. For the 16-bit one, you can do so or choose to use the included bootloader instead.

8 bits controller

The 8 bits controller is very limited by its addressable space and thus, is only equipped with a limited amount of peripherals.

The memory map is the following:

StartEndContent
0x000x7FInstructions
0x800xECData
0xED0xFFPeripherals
----------------
0xED0xF0Interrupt multiplexer
0xF10xF8GPIO
0xF90xFBTimer
0xFC0xFFUART

Top-level module

The top-level module is in the controller folder and is named reflet_8bit_controller. It can not be used as-is because there is no way to fill its instruction memory. To use it, you must copy the top-level module and replace the mem_inst module with a ROM.

The parameters for this module are the following:

NameDescriptionDefault value
clk_freqThe frequency of the main clock in Hertz.1 000 000
debug_outputWhen set to 1, enable the debug helper module.0
enable_interrupt_muxIf equal to 0, the interrupt multiplexer is disabled.1
enable_gpioIf equal to 0, the GPIOs are disabled.1
enable_timerIf equal to 0, the timer is disabled.1
enable_uartIf equal to 0, the UART is disabled.1
mem_resetableIf not set to 0, the memories are reset to 0 when the reset signal is pulled down. This can be incompatible with some FPGA's memory blocks.0

The ports of this module are the following:

NameTypeDescription
clkinputThe main clock.
resetinputReset the controller when flipped to low.
debugoutputTurned on for a clock cycle when the CPU executes a debug instruction.
debug_txoutputWhen debug_output is enabled, this line prints the content of the working register on debug instructions.
quitoutputIs turned on from the moment the CPU executes a quit instruction and stops itself.
gpi16-bit inputThe input of the GPIO.
gpo16-bit outputThe output of the GPIO.
rxinputThe rx line of the UART.
txoutputThe tx line of the UART.

16 bits controller

The 16 bits controller is equipped with all the peripherals and its bigger addressable space makes it way easier to program for.

The memory map is the following:

StartEndContent
0x00000x7CFFInstructions
0x7D000x7FFFBootloader
0x80000xFEFFData
0xFF000xFFFFPeripherals
-------------------
0xFF000xFF03Hardware info
0xFF040xFF07Interrupt multiplexer
0xFF080xFF0FGPIO
0xFF100xFF12Timer
0xFF130xFF15Timer 2
0xFF160xFF19UART
0xFF1A0xFF1BPWM
0xFF1C0xFF1ESeven segments controller
0xFF1F0xFF20Power manager
0xFF210xFF21Frequency synthesizer
0xFF220xFF23Extended IO

Top-level module

The top-level module is in the controller folder and is named reflet_16bit_controller. Unlike its 8-bit counterpart, it can be used on its own as it is equipped with a bootloader that can be used to load a program in the data memory. Of course, if it is needed to only use a single program with an implementation, the mem_inst module can be replaced with a ROM.

The parameters for this module are the following:

NameDescriptionDefault value
clk_freqThe frequency of the main clock in Hertz.1 000 000
debug_outputWhen set to 1, enable the debug helper module.0
enable_interrupt_muxIf equal to 0, the interrupt multiplexer is disabled.1
enable_gpioIf equal to 0, the GPIOs are disabled.1
enable_timerIf equal to 0, the timer is disabled.1
enable_timer2If equal to 0, the timer2 is disabled.1
enable_uartIf equal to 0, the UART is disabled.1
enable_pwmIf equal to 0, the PWM is disabled.1
enable_segmentsIf equal to 0, the seven segments display controller is disabled.1
enable_power_managerIf equal to 0, the power manager is disabled.1
enable_synthIf equal to 0, the frequency synthesizer is disabled.1
enable_ext_ioIf equal to 0, the extended IO is disabled.1
data_sizeSize in bytes of the data memory.100
inst_sizeSize in bytes of the instruction memory.128
mem_resetableIf not set to 0, the memories are reset to 0 when the reset signal is pulled down. This can be incompatible with some FPGA's memory blocks.0
ext_io_sizeThe size of the extended io ports.128
swift_bootloaderUse a 50 ms bootloader timeout instead of 4 s.0

The ports of this module are the following:

NameTypeDescription
clkinputThe main clock.
resetinputReset the controller when flipped to low.
reset_limitedinputReset the CPU, peripherals, and data memory but preserves the instruction memory.
debugoutputTurned on for a clock cycle when the CPU executes a debug instruction.
debug_txoutputWhen debug_output is enabled, this line prints the content of the working register on debug instructions.
quitoutputIs turned on from the moment the CPU executes a quit instruction and stops itself.
gpi16-bit inputThe input of the GPIO.
gpo16-bit outputThe output of the GPIO.
rxinputThe rx line of the UART.
txoutputThe tx line of the UART.
pwmoutputOutput of the PWM.
segments7-bit outputSeven-segment control, an output value of 0 means that the segment is on.
seg_select4-bit outputSeven segments digit selection, an output value of 1 means that the digit is selected.
seg_colonoutputControl of the colon indicator of the seven-segment display, a value of 0 means that the colon is turned on.
seg_dotoutputControl of the decimal dot indicator of the seven-segment display, a value of 0 means that the dot is turned on.
synth_outoutputOutput of the frequency synthesizer.
ext_io_inselectable size inputInput of the extended IO module.
ext_io_outselectable size outputOutput of the extended IO module.

Using the bootloader

The bootloader is very easy to use. After the processor started, transmit the program through the UART connection and wait 4 seconds for the program to start. If 4 seconds is too long, you can use the parameter swift_bootloader to lower it to 50 ms.

About

A micro-controller based on a Reflet CPU

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

195 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Reflet microcontroller

A micro-controller based on a Reflet CPU.

Part of the system are included as submodules, so you should run git submodule update --init --recursive after cloning this repository.

The CPU

The CPU is a Reflet CPU. More information and the toolchain can be found here: https://github.com/Arkaeriit/reflet.

Peripherals

All the Verilog files describing the peripherals and their submodules are in the peripheral folder.

All the peripherals are controlled and monitored with 8-bits registers to make them compatible with any Reflet CPU. Each register is only accessible with its exact address (even in 16-bit mode, editing the register at address 0xFF00 will not impact the register at address 0xFF01).

The peripherals are identified with a base address and are controlled by editing the register from the base address and a few bytes forwards. For example, with the 16-bit controller, the GPIO got 0xFF07 as its base address and is configured with the register at address 0xFF07 to 0xFF11.

To minimize the synthesis time and size of a reflet microcontroller, peripherals can be enabled or disabled with Verilog parameters.

Hardware info

This peripheral is always active. It is used to read the frequency of the system clock and which peripherals are enabled or not.

Offset with base addressTypeRegister nameEffect
0roclk_lsbContain the 8 LSB of the frequency of the main clock in MHz.
1roclk_msbContain the 8 MSB of the frequency of the main clock in MHz.
2roperiph_1Bits 0 to 2 contain info about the wordsize of the processor. 1 means that it is an 8-bit processor, 2 means a 16 bit, 3 32 bits, 4 64 bits, 5 128 bits, and 0 means any other wordsize. Bit 3 tells if the interrupt multiplexer is enabled. Bit 4 tells if the GPIO is enabled. Bit 5 tells if the timer is enabled. Bit 6 tells if the second timer is enabled. Finally, bit 7 tells if the UART is enabled.
3roperiph_2Bit 0 tells if the PWM is enabled. Bit 1 tells if the seven-segment controller is enabled. Bit 2 tells if the power manager is enabled. Bit 3 tells if the synthesizer is enabled. Bit 4 tells if the extended io is enabled. Bits 5 to 7 are left to 0.

Interrupt multiplexer

The CPU got only 4 interrupt lines, but more than 4 peripherals can raise interrupts. This module lets the user control which peripherals can use interrupts and the priority of each interrupt.

Offset with base addressTypeRegister nameEffect
0r/wint_enBit 0 control if the interrupt from the GPIO is enabled. Bit 1 control if the interrupt from the UART is enabled. Bit 2 control if the interrupt from the timer is enabled. Bit 3 control if the interrupt from timer 2 is enabled.
1r/wint_levelBits 0 and 1 control the priority of the GPIO interrupt. Bits 2 and 3 control the priority of the UART interrupt. Bits 4 and 5 control the priority of the timer interrupt. Bits 6 and 7 control the priority of the timer 2 interrupt.
2roreservedReserved for future used. Locked to 0 for now.
3r/wstatusThis register tells which interrupts are currently raised. Whenever a new interrupt appends, the related bit is raised to 1. To acknowledge the interrupt, its bit must be switched back to 0. Bit 0 tell the state of the GPIO interrupt. Bit 1 tells the state of the UART interrupt. Bit 2 tells the state of the timer interrupt. Bit 3 tells the state of the timer 2 interrupt.

GPIO

The most basic way to interact with the external world. It is made of a 16 bits parallel output and a 16 bits parallel input. The input can trigger an interrupt on the rising or falling edges of each input pin.

Offset with base addressTypeRegister nameEffect
0r/wgpo_lsbControl the 8 first pins of the parallel output.
1r/wgpo_msbControl the 8 last pins of the parallel output.
2rogpi_lsbContain the state of the 8 first pins of the parallel input.
3rogpi_msbContain the state of the 8 last pins of the parallel input.
4r/wrise_int_lsbControl which of the 8 first pins of the parallel input should raise an interrupt on a rising edge.
5r/wrise_int_msbControl which of the 8 last pins of the parallel input should raise an interrupt on a rising edge.
6r/wfall_int_lsbControl which of the 8 first pins of the parallel input should raise an interrupt on a falling edge.
7r/wfall_int_msbControl which of the 8 last pins of the parallel input should raise an interrupt on a falling edge.

Timer

A 24 bits timer. This timer contains two prescalers (pre1 and pre2) and the main counter (mcnt). Each of these 3 values is on 8 bits. The timer raise an interrupt each (pre1 + 1) * (pre2 + 1) * (mcnt) cycles of the system clock.

Offset with base addressTypeRegister nameEffect
0r/wpre1Control the value of pre1.
1r/wpre2Control the value of pre2.
2r/wmcntControl the value of mcnt.

Timer 2

A 23 bits timer. This timer behaves in a similar way to the main timer except that pre1 is on 7 bits instead of 8 and that we can select to use either the system clock or the output of the main timer as the input source. This makes it possible to chain timer and timer2 to have a resulting 47 bits timer.

Offset with base addressTypeRegister nameEffect
0r/wpre1Bit 0 should be set to 0 to use the system clock as an input source and set to 1 to use timer 1 as the input source. Bits 1 to 7 control the value of pre1.
1r/wpre2Control the value of pre2.
2r/wmcntControl the value of mcnt.

UART

A UART module with a baud rate locked at 9600. Its behavior is very similar to the IO functions of the Reflet simulator. To send a message, write its value in the tx_data register and put a 0 in tx_cmd. To receive a message, either enable the interrupt in the interrupt multiplexer or wait for the value in the rx_cmd register to be set to 0. The data will then be readable in the rx_data register.

Offset with base addressTypeRegister nameEffect
0r/wtx_cmdSet to 0 to send a message.
1r/wtx_dataWrite here the message to send.
2r/wrx_cmdThis register is automatically set to 0 when a byte is received.
3r/wrx_dataThe byte received is readable here.

PWM

A PWM module with up to 8 bits of resolution. Its frequency is configurable but the higher the frequency, the smaller the resolution. Its period is controllable with the freq register and its duty cycle with the duty register. The resulting duty cycle will be duty/freq.

Offset with base addressTypeRegister nameEffect
0r/wfreqSet the period of the PWM.
1r/wdutySet the duty-cycle.

Seven segments display controller

Even if this could be done with GPIO and a timer, a controller for seven segments display could be useful. This module is made to control 4 digits displays with colons and dots. In the selection bits, a 1 indicates that the digit is active. In the segments bits, 0 indicates that the segments must be lit.

Offset with base addressTypeRegister nameEffect
0r/wctrlBit 0 is used to enable or disable the display. Bit 1 is used to enable the colon. Bits 4 to 7 are used to select which dots must be turned on. Bits 2 and 3 are unused.
1r/wnum01Bits 0 to 3 are used to set the value of the first number. Bits 4 to 7 are used to set the value of the second number.
2r/wnum23Bits 0 to 3 are used to set the value of the third number. Bits 4 to 7 are used to set the value of the fourth number.

Power manager

This module is meant to either reduce the speed of the processor or disable it until an interrupt happens. To reduce the speed, a PWM signal is sent to the enable pin of the CPU.

Offset with base addressTypeRegister nameEffect
0r/wsleepWhen bit 0 is set to 1, the processor is disabled until a detected interrupt is raised. When bit 1 is set to 1, the processor is slowed down by a factor controlled in the power register. Bits 2 and 3 are unused. Bit 4 to 7 are used to tell if interrupts 0 to 3 are watched. If bit 4 is set to 1, the module will watch for interrupt 0 and unlock the processor if interrupt 0 is raised. Bit 5 will enable interrupt 1 and so on.
1r/wpowerThis register will let you choose the duty cycle to send to the enable pin of the CPU. The duty cycle is (the content of this register + 1)/256.

Frequency synthesizer

The documentation will come when the module will be done

Extended IO

If you need more than the 16 inputs and 16 outputs of the GPIO module, you can use this one to have up to 256 additional inputs and 256 output. The IOs can be selected with an address on a register and controlled with the other one. The inputs can not raise interrupt. The actual number of IO is chosen with a parameter of the controller module.

Offset with base addressTypeRegister nameEffect
0r/waddressSelect which IO is selected.
1r/wcontrolBit 0 contains the value in the selected input. Bit 1 contains the actual value of the selected output. To set the output, write the value you want in bit 2 and set bit 3 to 1. Bits 4 to 7 are unused.

Debug Helper

This module helps in debugging by printing over an UART line the content of the working register whenever a debug instruction is encountered. The data is sent at 9600 bauds in a little-endian fashion. When sending those data, the CPU is disabled to ensure that no debug instructions will be missed.

Controllers

The folder controller contains files used to make 8 bits or a 16 bits microcontroller with a Reflet CPU. As of now, for the 8-bit controller, you must copy the reflet_?bits_controller.v file and replace the data memory with a ROM with a valid Reflet program. For the 16-bit one, you can do so or choose to use the included bootloader instead.

8 bits controller

The 8 bits controller is very limited by its addressable space and thus, is only equipped with a limited amount of peripherals.

The memory map is the following:

StartEndContent
0x000x7FInstructions
0x800xECData
0xED0xFFPeripherals
----------------
0xED0xF0Interrupt multiplexer
0xF10xF8GPIO
0xF90xFBTimer
0xFC0xFFUART

Top-level module

The top-level module is in the controller folder and is named reflet_8bit_controller. It can not be used as-is because there is no way to fill its instruction memory. To use it, you must copy the top-level module and replace the mem_inst module with a ROM.

The parameters for this module are the following:

NameDescriptionDefault value
clk_freqThe frequency of the main clock in Hertz.1 000 000
debug_outputWhen set to 1, enable the debug helper module.0
enable_interrupt_muxIf equal to 0, the interrupt multiplexer is disabled.1
enable_gpioIf equal to 0, the GPIOs are disabled.1
enable_timerIf equal to 0, the timer is disabled.1
enable_uartIf equal to 0, the UART is disabled.1
mem_resetableIf not set to 0, the memories are reset to 0 when the reset signal is pulled down. This can be incompatible with some FPGA's memory blocks.0

The ports of this module are the following:

NameTypeDescription
clkinputThe main clock.
resetinputReset the controller when flipped to low.
debugoutputTurned on for a clock cycle when the CPU executes a debug instruction.
debug_txoutputWhen debug_output is enabled, this line prints the content of the working register on debug instructions.
quitoutputIs turned on from the moment the CPU executes a quit instruction and stops itself.
gpi16-bit inputThe input of the GPIO.
gpo16-bit outputThe output of the GPIO.
rxinputThe rx line of the UART.
txoutputThe tx line of the UART.

16 bits controller

The 16 bits controller is equipped with all the peripherals and its bigger addressable space makes it way easier to program for.

The memory map is the following:

StartEndContent
0x00000x7CFFInstructions
0x7D000x7FFFBootloader
0x80000xFEFFData
0xFF000xFFFFPeripherals
-------------------
0xFF000xFF03Hardware info
0xFF040xFF07Interrupt multiplexer
0xFF080xFF0FGPIO
0xFF100xFF12Timer
0xFF130xFF15Timer 2
0xFF160xFF19UART
0xFF1A0xFF1BPWM
0xFF1C0xFF1ESeven segments controller
0xFF1F0xFF20Power manager
0xFF210xFF21Frequency synthesizer
0xFF220xFF23Extended IO

Top-level module

The top-level module is in the controller folder and is named reflet_16bit_controller. Unlike its 8-bit counterpart, it can be used on its own as it is equipped with a bootloader that can be used to load a program in the data memory. Of course, if it is needed to only use a single program with an implementation, the mem_inst module can be replaced with a ROM.

The parameters for this module are the following:

NameDescriptionDefault value
clk_freqThe frequency of the main clock in Hertz.1 000 000
debug_outputWhen set to 1, enable the debug helper module.0
enable_interrupt_muxIf equal to 0, the interrupt multiplexer is disabled.1
enable_gpioIf equal to 0, the GPIOs are disabled.1
enable_timerIf equal to 0, the timer is disabled.1
enable_timer2If equal to 0, the timer2 is disabled.1
enable_uartIf equal to 0, the UART is disabled.1
enable_pwmIf equal to 0, the PWM is disabled.1
enable_segmentsIf equal to 0, the seven segments display controller is disabled.1
enable_power_managerIf equal to 0, the power manager is disabled.1
enable_synthIf equal to 0, the frequency synthesizer is disabled.1
enable_ext_ioIf equal to 0, the extended IO is disabled.1
data_sizeSize in bytes of the data memory.100
inst_sizeSize in bytes of the instruction memory.128
mem_resetableIf not set to 0, the memories are reset to 0 when the reset signal is pulled down. This can be incompatible with some FPGA's memory blocks.0
ext_io_sizeThe size of the extended io ports.128
swift_bootloaderUse a 50 ms bootloader timeout instead of 4 s.0

The ports of this module are the following:

NameTypeDescription
clkinputThe main clock.
resetinputReset the controller when flipped to low.
reset_limitedinputReset the CPU, peripherals, and data memory but preserves the instruction memory.
debugoutputTurned on for a clock cycle when the CPU executes a debug instruction.
debug_txoutputWhen debug_output is enabled, this line prints the content of the working register on debug instructions.
quitoutputIs turned on from the moment the CPU executes a quit instruction and stops itself.
gpi16-bit inputThe input of the GPIO.
gpo16-bit outputThe output of the GPIO.
rxinputThe rx line of the UART.
txoutputThe tx line of the UART.
pwmoutputOutput of the PWM.
segments7-bit outputSeven-segment control, an output value of 0 means that the segment is on.
seg_select4-bit outputSeven segments digit selection, an output value of 1 means that the digit is selected.
seg_colonoutputControl of the colon indicator of the seven-segment display, a value of 0 means that the colon is turned on.
seg_dotoutputControl of the decimal dot indicator of the seven-segment display, a value of 0 means that the dot is turned on.
synth_outoutputOutput of the frequency synthesizer.
ext_io_inselectable size inputInput of the extended IO module.
ext_io_outselectable size outputOutput of the extended IO module.

Using the bootloader

The bootloader is very easy to use. After the processor started, transmit the program through the UART connection and wait 4 seconds for the program to start. If 4 seconds is too long, you can use the parameter swift_bootloader to lower it to 50 ms.

About

A micro-controller based on a Reflet CPU

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

195 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Reflet microcontroller

A micro-controller based on a Reflet CPU.

Part of the system are included as submodules, so you should run git submodule update --init --recursive after cloning this repository.

The CPU

The CPU is a Reflet CPU. More information and the toolchain can be found here: https://github.com/Arkaeriit/reflet.

Peripherals

All the Verilog files describing the peripherals and their submodules are in the peripheral folder.

All the peripherals are controlled and monitored with 8-bits registers to make them compatible with any Reflet CPU. Each register is only accessible with its exact address (even in 16-bit mode, editing the register at address 0xFF00 will not impact the register at address 0xFF01).

The peripherals are identified with a base address and are controlled by editing the register from the base address and a few bytes forwards. For example, with the 16-bit controller, the GPIO got 0xFF07 as its base address and is configured with the register at address 0xFF07 to 0xFF11.

To minimize the synthesis time and size of a reflet microcontroller, peripherals can be enabled or disabled with Verilog parameters.

Hardware info

This peripheral is always active. It is used to read the frequency of the system clock and which peripherals are enabled or not.

Offset with base addressTypeRegister nameEffect
0roclk_lsbContain the 8 LSB of the frequency of the main clock in MHz.
1roclk_msbContain the 8 MSB of the frequency of the main clock in MHz.
2roperiph_1Bits 0 to 2 contain info about the wordsize of the processor. 1 means that it is an 8-bit processor, 2 means a 16 bit, 3 32 bits, 4 64 bits, 5 128 bits, and 0 means any other wordsize. Bit 3 tells if the interrupt multiplexer is enabled. Bit 4 tells if the GPIO is enabled. Bit 5 tells if the timer is enabled. Bit 6 tells if the second timer is enabled. Finally, bit 7 tells if the UART is enabled.
3roperiph_2Bit 0 tells if the PWM is enabled. Bit 1 tells if the seven-segment controller is enabled. Bit 2 tells if the power manager is enabled. Bit 3 tells if the synthesizer is enabled. Bit 4 tells if the extended io is enabled. Bits 5 to 7 are left to 0.

Interrupt multiplexer

The CPU got only 4 interrupt lines, but more than 4 peripherals can raise interrupts. This module lets the user control which peripherals can use interrupts and the priority of each interrupt.

Offset with base addressTypeRegister nameEffect
0r/wint_enBit 0 control if the interrupt from the GPIO is enabled. Bit 1 control if the interrupt from the UART is enabled. Bit 2 control if the interrupt from the timer is enabled. Bit 3 control if the interrupt from timer 2 is enabled.
1r/wint_levelBits 0 and 1 control the priority of the GPIO interrupt. Bits 2 and 3 control the priority of the UART interrupt. Bits 4 and 5 control the priority of the timer interrupt. Bits 6 and 7 control the priority of the timer 2 interrupt.
2roreservedReserved for future used. Locked to 0 for now.
3r/wstatusThis register tells which interrupts are currently raised. Whenever a new interrupt appends, the related bit is raised to 1. To acknowledge the interrupt, its bit must be switched back to 0. Bit 0 tell the state of the GPIO interrupt. Bit 1 tells the state of the UART interrupt. Bit 2 tells the state of the timer interrupt. Bit 3 tells the state of the timer 2 interrupt.

GPIO

The most basic way to interact with the external world. It is made of a 16 bits parallel output and a 16 bits parallel input. The input can trigger an interrupt on the rising or falling edges of each input pin.

Offset with base addressTypeRegister nameEffect
0r/wgpo_lsbControl the 8 first pins of the parallel output.
1r/wgpo_msbControl the 8 last pins of the parallel output.
2rogpi_lsbContain the state of the 8 first pins of the parallel input.
3rogpi_msbContain the state of the 8 last pins of the parallel input.
4r/wrise_int_lsbControl which of the 8 first pins of the parallel input should raise an interrupt on a rising edge.
5r/wrise_int_msbControl which of the 8 last pins of the parallel input should raise an interrupt on a rising edge.
6r/wfall_int_lsbControl which of the 8 first pins of the parallel input should raise an interrupt on a falling edge.
7r/wfall_int_msbControl which of the 8 last pins of the parallel input should raise an interrupt on a falling edge.

Timer

A 24 bits timer. This timer contains two prescalers (pre1 and pre2) and the main counter (mcnt). Each of these 3 values is on 8 bits. The timer raise an interrupt each (pre1 + 1) * (pre2 + 1) * (mcnt) cycles of the system clock.

Offset with base addressTypeRegister nameEffect
0r/wpre1Control the value of pre1.
1r/wpre2Control the value of pre2.
2r/wmcntControl the value of mcnt.

Timer 2

A 23 bits timer. This timer behaves in a similar way to the main timer except that pre1 is on 7 bits instead of 8 and that we can select to use either the system clock or the output of the main timer as the input source. This makes it possible to chain timer and timer2 to have a resulting 47 bits timer.

Offset with base addressTypeRegister nameEffect
0r/wpre1Bit 0 should be set to 0 to use the system clock as an input source and set to 1 to use timer 1 as the input source. Bits 1 to 7 control the value of pre1.
1r/wpre2Control the value of pre2.
2r/wmcntControl the value of mcnt.

UART

A UART module with a baud rate locked at 9600. Its behavior is very similar to the IO functions of the Reflet simulator. To send a message, write its value in the tx_data register and put a 0 in tx_cmd. To receive a message, either enable the interrupt in the interrupt multiplexer or wait for the value in the rx_cmd register to be set to 0. The data will then be readable in the rx_data register.

Offset with base addressTypeRegister nameEffect
0r/wtx_cmdSet to 0 to send a message.
1r/wtx_dataWrite here the message to send.
2r/wrx_cmdThis register is automatically set to 0 when a byte is received.
3r/wrx_dataThe byte received is readable here.

PWM

A PWM module with up to 8 bits of resolution. Its frequency is configurable but the higher the frequency, the smaller the resolution. Its period is controllable with the freq register and its duty cycle with the duty register. The resulting duty cycle will be duty/freq.

Offset with base addressTypeRegister nameEffect
0r/wfreqSet the period of the PWM.
1r/wdutySet the duty-cycle.

Seven segments display controller

Even if this could be done with GPIO and a timer, a controller for seven segments display could be useful. This module is made to control 4 digits displays with colons and dots. In the selection bits, a 1 indicates that the digit is active. In the segments bits, 0 indicates that the segments must be lit.

Offset with base addressTypeRegister nameEffect
0r/wctrlBit 0 is used to enable or disable the display. Bit 1 is used to enable the colon. Bits 4 to 7 are used to select which dots must be turned on. Bits 2 and 3 are unused.
1r/wnum01Bits 0 to 3 are used to set the value of the first number. Bits 4 to 7 are used to set the value of the second number.
2r/wnum23Bits 0 to 3 are used to set the value of the third number. Bits 4 to 7 are used to set the value of the fourth number.

Power manager

This module is meant to either reduce the speed of the processor or disable it until an interrupt happens. To reduce the speed, a PWM signal is sent to the enable pin of the CPU.

Offset with base addressTypeRegister nameEffect
0r/wsleepWhen bit 0 is set to 1, the processor is disabled until a detected interrupt is raised. When bit 1 is set to 1, the processor is slowed down by a factor controlled in the power register. Bits 2 and 3 are unused. Bit 4 to 7 are used to tell if interrupts 0 to 3 are watched. If bit 4 is set to 1, the module will watch for interrupt 0 and unlock the processor if interrupt 0 is raised. Bit 5 will enable interrupt 1 and so on.
1r/wpowerThis register will let you choose the duty cycle to send to the enable pin of the CPU. The duty cycle is (the content of this register + 1)/256.

Frequency synthesizer

The documentation will come when the module will be done

Extended IO

If you need more than the 16 inputs and 16 outputs of the GPIO module, you can use this one to have up to 256 additional inputs and 256 output. The IOs can be selected with an address on a register and controlled with the other one. The inputs can not raise interrupt. The actual number of IO is chosen with a parameter of the controller module.

Offset with base addressTypeRegister nameEffect
0r/waddressSelect which IO is selected.
1r/wcontrolBit 0 contains the value in the selected input. Bit 1 contains the actual value of the selected output. To set the output, write the value you want in bit 2 and set bit 3 to 1. Bits 4 to 7 are unused.

Debug Helper

This module helps in debugging by printing over an UART line the content of the working register whenever a debug instruction is encountered. The data is sent at 9600 bauds in a little-endian fashion. When sending those data, the CPU is disabled to ensure that no debug instructions will be missed.

Controllers

The folder controller contains files used to make 8 bits or a 16 bits microcontroller with a Reflet CPU. As of now, for the 8-bit controller, you must copy the reflet_?bits_controller.v file and replace the data memory with a ROM with a valid Reflet program. For the 16-bit one, you can do so or choose to use the included bootloader instead.

8 bits controller

The 8 bits controller is very limited by its addressable space and thus, is only equipped with a limited amount of peripherals.

The memory map is the following:

StartEndContent
0x000x7FInstructions
0x800xECData
0xED0xFFPeripherals
----------------
0xED0xF0Interrupt multiplexer
0xF10xF8GPIO
0xF90xFBTimer
0xFC0xFFUART

Top-level module

The top-level module is in the controller folder and is named reflet_8bit_controller. It can not be used as-is because there is no way to fill its instruction memory. To use it, you must copy the top-level module and replace the mem_inst module with a ROM.

The parameters for this module are the following:

NameDescriptionDefault value
clk_freqThe frequency of the main clock in Hertz.1 000 000
debug_outputWhen set to 1, enable the debug helper module.0
enable_interrupt_muxIf equal to 0, the interrupt multiplexer is disabled.1
enable_gpioIf equal to 0, the GPIOs are disabled.1
enable_timerIf equal to 0, the timer is disabled.1
enable_uartIf equal to 0, the UART is disabled.1
mem_resetableIf not set to 0, the memories are reset to 0 when the reset signal is pulled down. This can be incompatible with some FPGA's memory blocks.0

The ports of this module are the following:

NameTypeDescription
clkinputThe main clock.
resetinputReset the controller when flipped to low.
debugoutputTurned on for a clock cycle when the CPU executes a debug instruction.
debug_txoutputWhen debug_output is enabled, this line prints the content of the working register on debug instructions.
quitoutputIs turned on from the moment the CPU executes a quit instruction and stops itself.
gpi16-bit inputThe input of the GPIO.
gpo16-bit outputThe output of the GPIO.
rxinputThe rx line of the UART.
txoutputThe tx line of the UART.

16 bits controller

The 16 bits controller is equipped with all the peripherals and its bigger addressable space makes it way easier to program for.

The memory map is the following:

StartEndContent
0x00000x7CFFInstructions
0x7D000x7FFFBootloader
0x80000xFEFFData
0xFF000xFFFFPeripherals
-------------------
0xFF000xFF03Hardware info
0xFF040xFF07Interrupt multiplexer
0xFF080xFF0FGPIO
0xFF100xFF12Timer
0xFF130xFF15Timer 2
0xFF160xFF19UART
0xFF1A0xFF1BPWM
0xFF1C0xFF1ESeven segments controller
0xFF1F0xFF20Power manager
0xFF210xFF21Frequency synthesizer
0xFF220xFF23Extended IO

Top-level module

The top-level module is in the controller folder and is named reflet_16bit_controller. Unlike its 8-bit counterpart, it can be used on its own as it is equipped with a bootloader that can be used to load a program in the data memory. Of course, if it is needed to only use a single program with an implementation, the mem_inst module can be replaced with a ROM.

The parameters for this module are the following:

NameDescriptionDefault value
clk_freqThe frequency of the main clock in Hertz.1 000 000
debug_outputWhen set to 1, enable the debug helper module.0
enable_interrupt_muxIf equal to 0, the interrupt multiplexer is disabled.1
enable_gpioIf equal to 0, the GPIOs are disabled.1
enable_timerIf equal to 0, the timer is disabled.1
enable_timer2If equal to 0, the timer2 is disabled.1
enable_uartIf equal to 0, the UART is disabled.1
enable_pwmIf equal to 0, the PWM is disabled.1
enable_segmentsIf equal to 0, the seven segments display controller is disabled.1
enable_power_managerIf equal to 0, the power manager is disabled.1
enable_synthIf equal to 0, the frequency synthesizer is disabled.1
enable_ext_ioIf equal to 0, the extended IO is disabled.1
data_sizeSize in bytes of the data memory.100
inst_sizeSize in bytes of the instruction memory.128
mem_resetableIf not set to 0, the memories are reset to 0 when the reset signal is pulled down. This can be incompatible with some FPGA's memory blocks.0
ext_io_sizeThe size of the extended io ports.128
swift_bootloaderUse a 50 ms bootloader timeout instead of 4 s.0

The ports of this module are the following:

NameTypeDescription
clkinputThe main clock.
resetinputReset the controller when flipped to low.
reset_limitedinputReset the CPU, peripherals, and data memory but preserves the instruction memory.
debugoutputTurned on for a clock cycle when the CPU executes a debug instruction.
debug_txoutputWhen debug_output is enabled, this line prints the content of the working register on debug instructions.
quitoutputIs turned on from the moment the CPU executes a quit instruction and stops itself.
gpi16-bit inputThe input of the GPIO.
gpo16-bit outputThe output of the GPIO.
rxinputThe rx line of the UART.
txoutputThe tx line of the UART.
pwmoutputOutput of the PWM.
segments7-bit outputSeven-segment control, an output value of 0 means that the segment is on.
seg_select4-bit outputSeven segments digit selection, an output value of 1 means that the digit is selected.
seg_colonoutputControl of the colon indicator of the seven-segment display, a value of 0 means that the colon is turned on.
seg_dotoutputControl of the decimal dot indicator of the seven-segment display, a value of 0 means that the dot is turned on.
synth_outoutputOutput of the frequency synthesizer.
ext_io_inselectable size inputInput of the extended IO module.
ext_io_outselectable size outputOutput of the extended IO module.

Using the bootloader

The bootloader is very easy to use. After the processor started, transmit the program through the UART connection and wait 4 seconds for the program to start. If 4 seconds is too long, you can use the parameter swift_bootloader to lower it to 50 ms.

About

A micro-controller based on a Reflet CPU

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Latest commit

History

195 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Reflet microcontroller

A micro-controller based on a Reflet CPU.

Part of the system are included as submodules, so you should run git submodule update --init --recursive after cloning this repository.

The CPU

The CPU is a Reflet CPU. More information and the toolchain can be found here: https://github.com/Arkaeriit/reflet.

Peripherals

All the Verilog files describing the peripherals and their submodules are in the peripheral folder.

All the peripherals are controlled and monitored with 8-bits registers to make them compatible with any Reflet CPU. Each register is only accessible with its exact address (even in 16-bit mode, editing the register at address 0xFF00 will not impact the register at address 0xFF01).

The peripherals are identified with a base address and are controlled by editing the register from the base address and a few bytes forwards. For example, with the 16-bit controller, the GPIO got 0xFF07 as its base address and is configured with the register at address 0xFF07 to 0xFF11.

To minimize the synthesis time and size of a reflet microcontroller, peripherals can be enabled or disabled with Verilog parameters.

Hardware info

This peripheral is always active. It is used to read the frequency of the system clock and which peripherals are enabled or not.

Offset with base addressTypeRegister nameEffect
0roclk_lsbContain the 8 LSB of the frequency of the main clock in MHz.
1roclk_msbContain the 8 MSB of the frequency of the main clock in MHz.
2roperiph_1Bits 0 to 2 contain info about the wordsize of the processor. 1 means that it is an 8-bit processor, 2 means a 16 bit, 3 32 bits, 4 64 bits, 5 128 bits, and 0 means any other wordsize. Bit 3 tells if the interrupt multiplexer is enabled. Bit 4 tells if the GPIO is enabled. Bit 5 tells if the timer is enabled. Bit 6 tells if the second timer is enabled. Finally, bit 7 tells if the UART is enabled.
3roperiph_2Bit 0 tells if the PWM is enabled. Bit 1 tells if the seven-segment controller is enabled. Bit 2 tells if the power manager is enabled. Bit 3 tells if the synthesizer is enabled. Bit 4 tells if the extended io is enabled. Bits 5 to 7 are left to 0.

Interrupt multiplexer

The CPU got only 4 interrupt lines, but more than 4 peripherals can raise interrupts. This module lets the user control which peripherals can use interrupts and the priority of each interrupt.

Offset with base addressTypeRegister nameEffect
0r/wint_enBit 0 control if the interrupt from the GPIO is enabled. Bit 1 control if the interrupt from the UART is enabled. Bit 2 control if the interrupt from the timer is enabled. Bit 3 control if the interrupt from timer 2 is enabled.
1r/wint_levelBits 0 and 1 control the priority of the GPIO interrupt. Bits 2 and 3 control the priority of the UART interrupt. Bits 4 and 5 control the priority of the timer interrupt. Bits 6 and 7 control the priority of the timer 2 interrupt.
2roreservedReserved for future used. Locked to 0 for now.
3r/wstatusThis register tells which interrupts are currently raised. Whenever a new interrupt appends, the related bit is raised to 1. To acknowledge the interrupt, its bit must be switched back to 0. Bit 0 tell the state of the GPIO interrupt. Bit 1 tells the state of the UART interrupt. Bit 2 tells the state of the timer interrupt. Bit 3 tells the state of the timer 2 interrupt.

GPIO

The most basic way to interact with the external world. It is made of a 16 bits parallel output and a 16 bits parallel input. The input can trigger an interrupt on the rising or falling edges of each input pin.

Offset with base addressTypeRegister nameEffect
0r/wgpo_lsbControl the 8 first pins of the parallel output.
1r/wgpo_msbControl the 8 last pins of the parallel output.
2rogpi_lsbContain the state of the 8 first pins of the parallel input.
3rogpi_msbContain the state of the 8 last pins of the parallel input.
4r/wrise_int_lsbControl which of the 8 first pins of the parallel input should raise an interrupt on a rising edge.
5r/wrise_int_msbControl which of the 8 last pins of the parallel input should raise an interrupt on a rising edge.
6r/wfall_int_lsbControl which of the 8 first pins of the parallel input should raise an interrupt on a falling edge.
7r/wfall_int_msbControl which of the 8 last pins of the parallel input should raise an interrupt on a falling edge.

Timer

A 24 bits timer. This timer contains two prescalers (pre1 and pre2) and the main counter (mcnt). Each of these 3 values is on 8 bits. The timer raise an interrupt each (pre1 + 1) * (pre2 + 1) * (mcnt) cycles of the system clock.

Offset with base addressTypeRegister nameEffect
0r/wpre1Control the value of pre1.
1r/wpre2Control the value of pre2.
2r/wmcntControl the value of mcnt.

Timer 2

A 23 bits timer. This timer behaves in a similar way to the main timer except that pre1 is on 7 bits instead of 8 and that we can select to use either the system clock or the output of the main timer as the input source. This makes it possible to chain timer and timer2 to have a resulting 47 bits timer.

Offset with base addressTypeRegister nameEffect
0r/wpre1Bit 0 should be set to 0 to use the system clock as an input source and set to 1 to use timer 1 as the input source. Bits 1 to 7 control the value of pre1.
1r/wpre2Control the value of pre2.
2r/wmcntControl the value of mcnt.

UART

A UART module with a baud rate locked at 9600. Its behavior is very similar to the IO functions of the Reflet simulator. To send a message, write its value in the tx_data register and put a 0 in tx_cmd. To receive a message, either enable the interrupt in the interrupt multiplexer or wait for the value in the rx_cmd register to be set to 0. The data will then be readable in the rx_data register.

Offset with base addressTypeRegister nameEffect
0r/wtx_cmdSet to 0 to send a message.
1r/wtx_dataWrite here the message to send.
2r/wrx_cmdThis register is automatically set to 0 when a byte is received.
3r/wrx_dataThe byte received is readable here.

PWM

A PWM module with up to 8 bits of resolution. Its frequency is configurable but the higher the frequency, the smaller the resolution. Its period is controllable with the freq register and its duty cycle with the duty register. The resulting duty cycle will be duty/freq.

Offset with base addressTypeRegister nameEffect
0r/wfreqSet the period of the PWM.
1r/wdutySet the duty-cycle.

Seven segments display controller

Even if this could be done with GPIO and a timer, a controller for seven segments display could be useful. This module is made to control 4 digits displays with colons and dots. In the selection bits, a 1 indicates that the digit is active. In the segments bits, 0 indicates that the segments must be lit.

Offset with base addressTypeRegister nameEffect
0r/wctrlBit 0 is used to enable or disable the display. Bit 1 is used to enable the colon. Bits 4 to 7 are used to select which dots must be turned on. Bits 2 and 3 are unused.
1r/wnum01Bits 0 to 3 are used to set the value of the first number. Bits 4 to 7 are used to set the value of the second number.
2r/wnum23Bits 0 to 3 are used to set the value of the third number. Bits 4 to 7 are used to set the value of the fourth number.

Power manager

This module is meant to either reduce the speed of the processor or disable it until an interrupt happens. To reduce the speed, a PWM signal is sent to the enable pin of the CPU.

Offset with base addressTypeRegister nameEffect
0r/wsleepWhen bit 0 is set to 1, the processor is disabled until a detected interrupt is raised. When bit 1 is set to 1, the processor is slowed down by a factor controlled in the power register. Bits 2 and 3 are unused. Bit 4 to 7 are used to tell if interrupts 0 to 3 are watched. If bit 4 is set to 1, the module will watch for interrupt 0 and unlock the processor if interrupt 0 is raised. Bit 5 will enable interrupt 1 and so on.
1r/wpowerThis register will let you choose the duty cycle to send to the enable pin of the CPU. The duty cycle is (the content of this register + 1)/256.

Frequency synthesizer

The documentation will come when the module will be done

Extended IO

If you need more than the 16 inputs and 16 outputs of the GPIO module, you can use this one to have up to 256 additional inputs and 256 output. The IOs can be selected with an address on a register and controlled with the other one. The inputs can not raise interrupt. The actual number of IO is chosen with a parameter of the controller module.

Offset with base addressTypeRegister nameEffect
0r/waddressSelect which IO is selected.
1r/wcontrolBit 0 contains the value in the selected input. Bit 1 contains the actual value of the selected output. To set the output, write the value you want in bit 2 and set bit 3 to 1. Bits 4 to 7 are unused.

Debug Helper

This module helps in debugging by printing over an UART line the content of the working register whenever a debug instruction is encountered. The data is sent at 9600 bauds in a little-endian fashion. When sending those data, the CPU is disabled to ensure that no debug instructions will be missed.

Controllers

The folder controller contains files used to make 8 bits or a 16 bits microcontroller with a Reflet CPU. As of now, for the 8-bit controller, you must copy the reflet_?bits_controller.v file and replace the data memory with a ROM with a valid Reflet program. For the 16-bit one, you can do so or choose to use the included bootloader instead.

8 bits controller

The 8 bits controller is very limited by its addressable space and thus, is only equipped with a limited amount of peripherals.

The memory map is the following:

StartEndContent
0x000x7FInstructions
0x800xECData
0xED0xFFPeripherals
----------------
0xED0xF0Interrupt multiplexer
0xF10xF8GPIO
0xF90xFBTimer
0xFC0xFFUART

Top-level module

The top-level module is in the controller folder and is named reflet_8bit_controller. It can not be used as-is because there is no way to fill its instruction memory. To use it, you must copy the top-level module and replace the mem_inst module with a ROM.

The parameters for this module are the following:

NameDescriptionDefault value
clk_freqThe frequency of the main clock in Hertz.1 000 000
debug_outputWhen set to 1, enable the debug helper module.0
enable_interrupt_muxIf equal to 0, the interrupt multiplexer is disabled.1
enable_gpioIf equal to 0, the GPIOs are disabled.1
enable_timerIf equal to 0, the timer is disabled.1
enable_uartIf equal to 0, the UART is disabled.1
mem_resetableIf not set to 0, the memories are reset to 0 when the reset signal is pulled down. This can be incompatible with some FPGA's memory blocks.0

The ports of this module are the following:

NameTypeDescription
clkinputThe main clock.
resetinputReset the controller when flipped to low.
debugoutputTurned on for a clock cycle when the CPU executes a debug instruction.
debug_txoutputWhen debug_output is enabled, this line prints the content of the working register on debug instructions.
quitoutputIs turned on from the moment the CPU executes a quit instruction and stops itself.
gpi16-bit inputThe input of the GPIO.
gpo16-bit outputThe output of the GPIO.
rxinputThe rx line of the UART.
txoutputThe tx line of the UART.

16 bits controller

The 16 bits controller is equipped with all the peripherals and its bigger addressable space makes it way easier to program for.

The memory map is the following:

StartEndContent
0x00000x7CFFInstructions
0x7D000x7FFFBootloader
0x80000xFEFFData
0xFF000xFFFFPeripherals
-------------------
0xFF000xFF03Hardware info
0xFF040xFF07Interrupt multiplexer
0xFF080xFF0FGPIO
0xFF100xFF12Timer
0xFF130xFF15Timer 2
0xFF160xFF19UART
0xFF1A0xFF1BPWM
0xFF1C0xFF1ESeven segments controller
0xFF1F0xFF20Power manager
0xFF210xFF21Frequency synthesizer
0xFF220xFF23Extended IO

Top-level module

The top-level module is in the controller folder and is named reflet_16bit_controller. Unlike its 8-bit counterpart, it can be used on its own as it is equipped with a bootloader that can be used to load a program in the data memory. Of course, if it is needed to only use a single program with an implementation, the mem_inst module can be replaced with a ROM.

The parameters for this module are the following:

NameDescriptionDefault value
clk_freqThe frequency of the main clock in Hertz.1 000 000
debug_outputWhen set to 1, enable the debug helper module.0
enable_interrupt_muxIf equal to 0, the interrupt multiplexer is disabled.1
enable_gpioIf equal to 0, the GPIOs are disabled.1
enable_timerIf equal to 0, the timer is disabled.1
enable_timer2If equal to 0, the timer2 is disabled.1
enable_uartIf equal to 0, the UART is disabled.1
enable_pwmIf equal to 0, the PWM is disabled.1
enable_segmentsIf equal to 0, the seven segments display controller is disabled.1
enable_power_managerIf equal to 0, the power manager is disabled.1
enable_synthIf equal to 0, the frequency synthesizer is disabled.1
enable_ext_ioIf equal to 0, the extended IO is disabled.1
data_sizeSize in bytes of the data memory.100
inst_sizeSize in bytes of the instruction memory.128
mem_resetableIf not set to 0, the memories are reset to 0 when the reset signal is pulled down. This can be incompatible with some FPGA's memory blocks.0
ext_io_sizeThe size of the extended io ports.128
swift_bootloaderUse a 50 ms bootloader timeout instead of 4 s.0

The ports of this module are the following:

NameTypeDescription
clkinputThe main clock.
resetinputReset the controller when flipped to low.
reset_limitedinputReset the CPU, peripherals, and data memory but preserves the instruction memory.
debugoutputTurned on for a clock cycle when the CPU executes a debug instruction.
debug_txoutputWhen debug_output is enabled, this line prints the content of the working register on debug instructions.
quitoutputIs turned on from the moment the CPU executes a quit instruction and stops itself.
gpi16-bit inputThe input of the GPIO.
gpo16-bit outputThe output of the GPIO.
rxinputThe rx line of the UART.
txoutputThe tx line of the UART.
pwmoutputOutput of the PWM.
segments7-bit outputSeven-segment control, an output value of 0 means that the segment is on.
seg_select4-bit outputSeven segments digit selection, an output value of 1 means that the digit is selected.
seg_colonoutputControl of the colon indicator of the seven-segment display, a value of 0 means that the colon is turned on.
seg_dotoutputControl of the decimal dot indicator of the seven-segment display, a value of 0 means that the dot is turned on.
synth_outoutputOutput of the frequency synthesizer.
ext_io_inselectable size inputInput of the extended IO module.
ext_io_outselectable size outputOutput of the extended IO module.

Using the bootloader

The bootloader is very easy to use. After the processor started, transmit the program through the UART connection and wait 4 seconds for the program to start. If 4 seconds is too long, you can use the parameter swift_bootloader to lower it to 50 ms.

About

A micro-controller based on a Reflet CPU

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages