This project is a custom Instruction Set Architecture (ISA) extension based on RISC-V It adds health-related functionality such as height, weight, BMI, and BMR (Basal Metabolic Rate) calculations, using custom instructions implemented in Verilog.
Each MEM[index] represents a user record, containing:
- Height (in centimeters)
- Weight (in kilograms)
- BMI (Body Mass Index)
- BMR (Basal Metabolic Rate)
| Instruction | Description |
|---|---|
SET_HEIGHT Rn, value |
Set user height in centimeters |
SET_WEIGHT Rn, value |
Set user weight in kilograms |
CALC_BMI Rn |
Calculate BMI = weight / (height in m)^2 |
CALC_BMR Rn, gender, age |
Calculate BMR using Mifflin-St Jeor Equation |
Rnspecifies the user index (i.e., MEM[ Rn ])
- This custom ISA extension includes two types of instructions: I-type for setting user data, and R-type for computing results. All data is stored in memory where each MEM[user_index] holds a pair of values: height and weight.
MEM[user_index] = {
height (cm), // 32-bit
weight (kg) // 32-bit
}| Instruction | Type | OpcodeοΌ7-bitοΌ |
|---|---|---|
| SET_HEIGHT | I-type | 0001011 |
| SET_WEIGHT | I-type | 0001011 |
| CALC_BMI | R-type | 0001101 |
| CALC_BMR | R-type | 0001110 |
- Used to directly set height or weight for a user. | 31β20 | 19β15 | 14β12 | 11β7 | 6β0 | | imm | rs1 | funct3| rd | opcode |
- rd: user index β selects MEM[user_index]
- imm: 12-bit immediate height or weight value
- funct3: field selector: 0 = height, 1 = weight
- MEM[rd] = value stored in rs1 + imm
SET_HEIGHT x1, 180 // Set height = 180 cm for MEM[x1]
SET_WEIGHT x1, 75 // Set weight = 75 kg for MEM[x1]- Used to compute BMI or BMR from the user's stored height and weight. The result is written into rs2. | 31β25 | 24β20 | 19β15 | 14β12 | 11β7 | 6β0 | | funct7 | rs2 | rs1 | funct3| rd | opcode |
- rs1: user index β source of height/weight
- rs2: destination register to hold the result
- rd: operation selector
- funct7: used to encode additional parameters:
- For BMR: [6] = gender (0=female, 1=male), [5:0] = age (0β63)
CALC_BMI x2, x1 // Compute BMI for user x1, store result in x2
CALC_BMR x2, x1, M25 // Compute BMR for user x1 (male, age 25), store result in x2In BMR instruction, funct7 = 0b1_011001 (gender=1, age=25)