{"id":23031107,"url":"https://github.com/kevin-pottier/socn","last_synced_at":"2026-01-11T05:52:26.445Z","repository":{"id":266535656,"uuid":"898378265","full_name":"Kevin-Pottier/SOCN","owner":"Kevin-Pottier","description":"Design and implementation of an ASIC with an 8051 microcontroller core. Includes VHDL modules, C applications, RTL simulations, and mixed-signal validation. Focused on hardware-software co-design and optimization.","archived":false,"fork":false,"pushed_at":"2025-01-04T17:55:53.000Z","size":2057,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-04T18:33:43.370Z","etag":null,"topics":["8051-architecture","asic-design","digital-circuit-optimization","embedded-systems","hardware-software-co-design","logic-synthesis","microcontroller-integration","mixed-signal-simulation","rtl-simulation","vhdl"],"latest_commit_sha":null,"homepage":"","language":"VHDL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kevin-Pottier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-04T09:37:44.000Z","updated_at":"2025-01-04T17:55:57.000Z","dependencies_parsed_at":"2024-12-06T08:18:45.482Z","dependency_job_id":null,"html_url":"https://github.com/Kevin-Pottier/SOCN","commit_stats":null,"previous_names":["jegheterkevin1/socn","kevin-pottier/socn"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kevin-Pottier%2FSOCN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kevin-Pottier%2FSOCN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kevin-Pottier%2FSOCN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kevin-Pottier%2FSOCN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kevin-Pottier","download_url":"https://codeload.github.com/Kevin-Pottier/SOCN/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237801534,"owners_count":19368575,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["8051-architecture","asic-design","digital-circuit-optimization","embedded-systems","hardware-software-co-design","logic-synthesis","microcontroller-integration","mixed-signal-simulation","rtl-simulation","vhdl"],"created_at":"2024-12-15T15:33:51.549Z","updated_at":"2026-01-11T05:52:26.399Z","avatar_url":"https://github.com/Kevin-Pottier.png","language":"VHDL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Synthesis Project: Integrating an MCU into an ASIC\n\nThis project focuses on designing an ASIC embedding a microcontroller based on the 8051 architecture. It is conducted as part of the ESEO-EOC program for the 2024-2025 academic year and consists of several practical sessions.\n\n## Objectives\n\n- **Design of custom digital circuits**: Learn how to integrate a microcontroller into an ASIC.\n- **Development of embedded applications**: Create C and assembly applications to utilize the integrated microcontroller.\n- **Logical synthesis and simulation**: Validate the design through simulations and optimize the circuit in terms of area, frequency, and power consumption.\n\n---\n\n## Project Overview\n\n### Project Architecture\nThe ASIC is built around an 8051 microcontroller core with specific peripherals, including:\n- A **digital sinusoidal signal generator**.\n- A **programmable timer**.\n- A **brown-out detector (BOD)** to manage power-on conditions.\n\n### Key Steps\n\n1. **Day 1: Coding and RTL Simulation**\n   - Write an embedded application in C.\n   - Perform RTL simulation (behavioral model) to validate the integration of the CPU and application.\n\n2. **Day 2: Peripherals Design and Integration**\n   - Specify and implement a timer in VHDL.\n   - Conduct a full system simulation with the modified application.\n\n3. **Day 3: Logic Synthesis**\n   - Analyze timing and resource usage.\n   - Perform netlist simulations (functional and annotated).\n\n4. **Day 4: Optimization**\n   - Conduct static timing analysis.\n   - Optimize the circuit for area, frequency, and power consumption.\n\n5. **Day 5: Mixed Simulation**\n   - Integrate an analog model (voltage supervisor) using VHDL-AMS.\n   - Perform mixed simulation with SPICE + VHDL-AMS.\n\n---\n\n## Project Structure\n\n### Directories\n\n- `VHDL/`: Contains VHDL files for CPU and peripheral modules.\n- `C/`: Embedded applications written in C.\n- `Scripts/`: Scripts for compilation and simulation.\n- `Doc/`: Technical documentation, including the 8051 instruction set.\n\n### Key Files\n\n- `TopAppliS51.vhdl`: Description of the top-level VHDL module.\n- `Makefile_soft`: Makefile for compiling C applications.\n- `Makefile_msim`: Makefile for compiling and simulating hardware designs.\n- `gensin.c`: Application generating a sinusoidal signal.\n- `S51Timer.vhdl`: Description of the timer peripheral.\n\n---\n\n## Getting Started\n\n1. **Install the Project**\n   ```bash\n   git clone https://github.com/Kevin-Pottier/SOCN.git\n   cd SOCN\n   ```\n\n# DAY 1: Sinusoidal Signal Generator for an 8051 Microcontroller on ASIC\n\nThis project demonstrates the implementation of a sinusoidal signal generator using an 8051 microcontroller integrated into an ASIC. It covers coding in C, assembly adjustments, VHDL modifications, and ModelSim simulations, while addressing various challenges encountered during the design and implementation phases.\n\n---\n\n## Overview\n\nThe main objective of this project is to generate a sine wave using the 8051 microcontroller by:\n1. Calculating sine values programmatically in C.\n2. Storing these values in the ROM of the microcontroller.\n3. Displaying the sine wave on an output register in a VHDL-implemented system.\n\nThe project highlights real-world design and debugging challenges, including bypassing startup code, handling timing issues, and implementing missing instructions.\n\n---\n\n## Implementation Steps and Explanations\n\n### Step 1: Coding the Initial C File\n\n#### Objective\nGenerate a sine wave table programmatically using the C programming language, store it in ROM, and prepare it for simulation.\n\n#### Process\n1. Write a C program (`gensin.c`) to calculate sine values for the desired number of points:\n   ```c\n   sin(i * 2.0 * M_PI / nbpoints)\n   ```\n\nthen compile the file \n   ```bash\n   make -f Makefile_soft SRC=test all  # Compile the C code\n   make compile_msim                  # Compile the VHDL model\n   make sim \u0026                          # Launch ModelSim\n   ```\n\nProblem: Program Counter Halts\n\n- Observation: The Program Counter (PC) stopped at a specific address in ModelSim.\n- Analysis: The startup code could not execute due to missing initialization logic.\n- Solution: Bypass the startup code by jumping directly into the main function. Modify line 180 in test.asm:\n\n   ```asm\n   LJMP _main\n   ```\n\n- Then restart the simulation on ModelSim\n   ```bash\n   restart -f\n   run 80us\n   ```\n\n### Step 2: Storing the Sine Table in ROM\n\n#### Objective\nStore the sine wave values generated from the C program in the ROM to save RAM space and ensure they persist during program execution.\n\n---\n\n#### Process\n\n1. **Generate Sine Values**  \n   Use the `gensin.c` program to compute sine wave values normalized between 0 and 255. The values will be stored in an array to be later placed in ROM.\n\n2. **Copy Values to ROM**  \n   Insert the generated sine values into the `SINV[]` array in the `gensin_simple.c` file. Use the `_code` keyword to ensure the array is stored in ROM:\n   ```c\n   _code unsigned char SINV[] = {\n       127, 135, 143, 151, 159, 166, 174, 181, 188, 195, 202, 208, 214, 220, \n       225, 230, 235, 239, 242, 246, 248, 250, 252, 253, 254, 255, 254, 253,\n       252, 250, 248, 246, 242, 239, 235, 230, 225, 220, 214, 208, 202, 195,\n       188, 181, 174, 166, 159, 151, 143, 135, 127, 119, 111, 103, 95, 88,\n       80, 73, 66, 59, 52, 46, 40, 34, 29, 24, 19, 15, 12, 8, 6, 4, 2, 1, 0\n   };\n   ```\n3. **Compile the Software**\n   Compile the updated C file to generate the corresponding assembly:\n   ```bash\n   make -f Makefile_soft SRC=gensin_simple all\n   ```\n4. **Adjust Assembly for ROM Usage**\nOpen the gensin_simple.asm file and find line 180. Replace the startup code reference with _main to jump directly into the main program:\n    ```asm\n      LJMP _main\n    ```\n5. **Recompile the Assembly**\nRecompile the assembly code to ensure the changes are applied:\n   ```bash\n   make -f Makefile_soft SRC=gensin_simple asm\n   ```\n### Step 3: Adjusting the VHDL Implementation\n\n#### Objective\nEnable the CPU to process the sine wave generation loop by implementing missing instructions (`mov16`) and ensuring the VHDL design supports their execution.\n\n---\n\n#### Process\n\n1. **Identify Missing Instruction**  \n   During simulation, it was observed that the `mov16` instruction, used for moving 16-bit data, was not implemented in the VHDL CPU model. This caused the program to hang during execution.\n\n2. **Modify the VHDL Code**  \n   Open the `DAX.vhdl` file in the `VHDL/S51CPU/` directory and locate the section handling the `mov16` instruction. Add the following logic:\n   - Specify the size of the operand:\n     ```vhdl\n     OpNb \u003c= 3;\n     ```\n   - Set the control signal for the `mov16` operation:\n     ```vhdl\n     CMDDPTRISEL \u003c= CMDDPTRIDATA16;\n     ```\n\n3. **Compile the Updated VHDL Code**  \n   Recompile the VHDL files to apply the changes:\n   ```bash\n   make compile_msim\n4. **Simulate and Verify**\nLaunch ModelSim to verify the sine wave generation:\n   ```bash\n   make sim \u0026\n   ```\n- Observe the output register `P` in the simulation waveform. The sine wave values should now be visible, indicating that the `mov16` instruction is functioning correctly.\n\n### Step 4: Correcting the Sine Wave Period\n\n#### Objective\nEnsure the sine wave output has the correct period of 1 ms as specified in the project requirements.\n\n---\n\n#### Problem\n- **Observation:** The generated sine wave had a period of 40 µs instead of the expected 1 ms.\n- **Analysis:** Each sine sample was being output every 400 ns due to the loop executing too quickly, resulting in a sine wave that was 25 times faster than required.\n\n---\n\n#### Process\n\n1. **Calculate Required Delay**  \n   - Each sine sample should be output every 10,000 ns (1 ms period for 100 samples).\n   - The current delay per sample is only 400 ns.\n   - The additional delay required:  \n     ```\n     10,000 ns - 400 ns = 9,600 ns\n     ```\n   - Each `nop` (no-operation) instruction introduces a 50 ns delay. Therefore, the number of `nop` instructions required:\n     ```\n     9,600 ns ÷ 50 ns = 192 nops\n     ```\n\n2. **Add `nop` Instructions**  \n   - Insert 192 `nop` instructions into the assembly loop to create the required delay:\n     ```asm\n     nop\n     nop\n     nop\n     ...\n     ```\n\n3. **Recompile the Assembly**  \n   Compile the updated assembly file to apply the changes:\n   ```bash\n   make -f Makefile_soft SRC=gensin_simple asm\n   ```\n   \n4. **Simulate and Verify**\n\n   - Run the simulation in ModelSim to observe the updated sine wave:\n   ```bash\n   make sim \u0026\n   \n- Check the output register `P` in the waveform and confirm the sine wave period is now `1 ms`.\n\n1. **Additional Issues and Solutions**\n   - `sjump` Range Limitation\n   - Problem: The sjump (short jump) instruction used in the loop has a maximum range of 128 bytes, but the added nop instructions caused the loop to exceed this range.\n   - Solution: Replace sjump with a ljump (long jump) to handle the extended range:\n   ```asm\n    ljmp target_label\n   ```\n2. **Conditional Jump (jc) Limitation**\n   - Problem: A jc (conditional jump) cannot directly be replaced with a long jump.\n   - Solution: Use a dummy label to redirect the jc to a long jump:\n   ```asm\n    jc dummy_label\n    dummy_label: ljmp target_label\n   ```\n3. **Loop Overhead**\n    - Problem: A small timing discrepancy of 50 ns remained due to the overhead of reinitializing the loop counter (i).\n    - Solution: Document the overhead and note it for future optimization.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevin-pottier%2Fsocn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevin-pottier%2Fsocn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevin-pottier%2Fsocn/lists"}