Notes, summaries, assignments, exams, and problems for Computer science

VHDL Implementations for Digital Logic Circuits

Computer science4.7 KB

VHDL Code Examples for Digital Logic Design

This document presents several VHDL code examples demonstrating the implementation of various digital logic circuits, including custom combinational functions and a priority encoder. These examples illustrate fundamental VHDL constructs for hardware description.

Custom Combinational Logic Function (EFC_17_F) - Decoder Label

This VHDL module, named EFC_17_F, implements a specific combinational logic function. In the original context, it was labeled as a "decoder." It takes four standard logic inputs (P1, P0, M1, M0) and produces a single standard logic output (C). The output C is asserted ('1') for specific input combinations, effectively acting as a custom boolean function.


LIBRARY IEEE;
USE IEEE.STD_
...
Continue reading "VHDL Implementations for Digital Logic Circuits" »

Java MySQL CRUD Operations Code Snippets

Computer science3.07 KB

Conexão

try {
    Class.forName("com.mysql.jdbc.Driver");
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/", "root", "abc123");
} catch (ClassNotFoundException dri) {
    System.out.println("Erro ao carregar o driver" + dri.getMessage());
} catch (SQLException sql) {
    System.out.println("Erro ao conectar ao banco de dados" + sql.getMessage());
} catch (Exception e) {
    throw new RuntimeException(e);
}

Insert

Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/", "root", "abc123");
String sql = "insert into dados.Pessoa (nome, idade, sexo) values (?, ?, ?)";
try {
    PreparedStatement stmt = con.prepareStatement(sql);
    Pessoa p = (Pessoa) o;
    stmt.setString(1, p.getNome());
    stmt.
...
Continue reading "Java MySQL CRUD Operations Code Snippets" »

Core Operating System Concepts: Processes, Shells, and Security

Computer science95.39 KB

Operations on a Process

  1. Process Creation: A user request or an already running process can create new processes. A parent process creates child processes using a system call, which, in turn, can create other processes, forming a tree of processes.
  2. Process Pre-emption: A process is pre-empted if an I/O event or timeout occurs. The process then moves from the running state to the ready state, and the CPU loads another process from the ready state to the running state, if available.
  3. Process Blocking: When a process requires an I/O event during its execution, it moves from the running state to the waiting state, and the CPU dispatches another process.
  4. Process Termination: A process is terminated when it completes its execution. Additionally, events
...
Continue reading "Core Operating System Concepts: Processes, Shells, and Security" »

Java Code Examples: Word Count, Fibonacci, Stack & Queue

Computer science6.62 KB

Class: CountOccurrenceOfWords

This class demonstrates how to count the occurrences of words in a given text string using a TreeMap to maintain sorted word counts.

public class CountOccurrenceOfWords {
    public static void main(String[] args) {
        // Set text in a string
        String text = "Good morning. Have a good class. " +
                      "Have a good visit. Have fun!";

        // Create a TreeMap to hold words as keys and counts as values
        Map<String, Integer> map = new TreeMap<>();

        String[] words = text.split("[ \n\t\r.,;:!?()]+");
        for (int i = 0; i < words.length; i++) {
            String key = words[i].toLowerCase();
            if (key.length() > 0) {
                if (!map.
...
Continue reading "Java Code Examples: Word Count, Fibonacci, Stack & Queue" »

Effective Interface and Report Design Strategies

Computer science2.96 KB

Designing Forms and Reports

  • Process of designing forms and reports
  • General guidelines for formatting forms and reports

Designing Interfaces and Dialogues

  • Process of designing interfaces and dialogues
  • General guidelines for interface design
  • Guidelines for the design of human-computer dialogues

Designing Web and Mobile Interfaces

  • General guidelines
  • Principles of mobile interface design

Understanding Forms and Reports

What is a Form?

A form is a business document that contains predefined data and may include areas where additional data is to be filled in. Traditionally, forms are paper-based. Today, the layout of almost any paper-based form can be displayed on a video display. Form interaction is a standard method for gathering and displaying information...

Continue reading "Effective Interface and Report Design Strategies" »

C++ Program for 2D Transformations in Graphics

Computer science2.87 KB

C++ Program for 2D Transformations

Write your text here! #include<iostream>

#include<graphics.h>
using namespace std;

int main()
{
    int gd = DETECT,gm,ch;
    initgraph(&gd,&gm,NULL);
    cleardevice();
    long int x1 = 30,y1 = 30,x2 = 70,y2 = 70;
    int y = 2,x = 2;

    do
    {
        cout<<"\n2-D TRANSFORMATIONS";
        cout<<"\n1.Translation";
        cout<<"\n2.Rotation";
        cout<<"\n3.Scaling";
        cout<<"\n4.Exit";
        cout<<"\nEnter your choice ";
        cin>>ch;

        switch(ch)
        {
            case 1:
                long int tx,ty;
                cout<<"\nEnter x1 coordinate ";
                cin>>x1;
                cout<
...
Continue reading "C++ Program for 2D Transformations in Graphics" »

MPEG Multimedia Standards and Descriptors Quiz

Computer science2.4 KB

1. Which of the following statements about MPEG is not correct?

  • a. MPEG-1/2/4 are multimedia standards related to video and audio compression.
  • b. MPEG-7 is a multimedia content description standard that standardizes the extraction process and usage of audiovisual descriptors.
  • c. MPEG-7 is a multimedia content description standard that standardizes the syntax and semantics of audiovisual descriptors.

2. The Dominant Color Descriptor (DCD) captures…

  • a. The spatial distribution of the colors in an image using by default the YUV color space.
  • b. A maximum of eight representative colors using by default the RGB color space.
  • c. All the colors in the RGB color space with a larger percentage than 10.

3. The Color Structure Descriptor (CSD)…

  • a. Does not capture
...
Continue reading "MPEG Multimedia Standards and Descriptors Quiz" »

Key Concepts in IT: Client Facilities, XML, and Security

Computer science3.59 KB

Client Facilities

Client Facilities: Performance, ensure integrity, updates, risk confidential. Static pages, forms, active content, plugins, stand-alone applications.

XML

XML (Extensible Markup Language): Preferred form for B2B and internal documents with legal effect. Key benefits: non-proprietary, platform independent, HTTP compatibility, international support, extensible, self-defining, common tools, and transformation. Complementary techniques: UDDI (Universal Description, Discovery, and Integration), WSDL (Web Services Description Language) – web service design. Signatures have legal effect.

Components

Components: Good because turn-key systems tend to be too large and inflexible. Advantages: higher quality and design, maintenance shared,...

Continue reading "Key Concepts in IT: Client Facilities, XML, and Security" »

Java JDBC MySQL Connection and Car Table Management

Computer science2.75 KB

Java JDBC Connection and Cars Table in MySQL

public static Connection conexionBD(String BDNombre) throws SQLException {
Connection con = null;
try {
System.out.println("Connecting...");
String controlador = "com.mysql.jdbc.Driver";
Class.forName(controlador).newInstance();
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/bdtest", "usuario", "contraseña");
System.out.println("Connection succeeded!");
} catch (Exception e) {
e.printStackTrace();
}
return con;
}
public static void createCOCHES(Connection con, String BDNombre) throws SQLException {
String createString = "create table if not exists " + BDNombre + ".coches " +
"(matricula varchar(8) not null," +
...
Continue reading "Java JDBC MySQL Connection and Car Table Management" »

Cybersecurity Fundamentals: Threats, CIA Triangle, and System Components

Computer science3.63 KB

Essential Concepts in Information Security

Threat vs. Threat Agent: Key Distinctions

The word “threat” usually stands for a category of things that pose a potential danger. Viruses, worms, and other types of malware, for example, are threats. A “threat agent,” by contrast, is a specific threat, or a specific type of virus, worm, or other malware. For example, the Blaster Worm is a threat agent.

Vulnerability vs. Exposure in Security Systems

Vulnerability is a fault within the system, such as software package flaws, unlocked doors, or an unprotected system port. It leaves things open to an attack or damage.

Exposure is a single instance when a system is open to damage. Vulnerabilities can in turn be the cause of exposure.

Infrastructure Protection

...
Continue reading "Cybersecurity Fundamentals: Threats, CIA Triangle, and System Components" »